CMS 3D CMS Logo

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

#include <TtFullLepHypGenMatch.h>

Inheritance diagram for TtFullLepHypGenMatch:
TtFullLepHypothesis edm::EDProducer edm::ProducerBase edm::EDConsumerBase 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 ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

edm::EDGetTokenT< TtGenEventgenEvtToken_
 
- Protected Attributes inherited from TtFullLepHypothesis
reco::ShallowClonePtrCandidateb_
 
reco::ShallowClonePtrCandidatebBar_
 
edm::EDGetTokenT< std::vector
< pat::Electron > > 
elecsToken_
 
bool getMatch_
 
std::string jetCorrectionLevel_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetsToken_
 
int key_
 hypothesis key (to be set by the buildKey function) More...
 
reco::ShallowClonePtrCandidatelepton_
 
reco::ShallowClonePtrCandidateleptonBar_
 
edm::EDGetTokenT< std::vector
< std::vector< int > > > 
matchToken_
 input label for all necessary collections More...
 
edm::EDGetTokenT< std::vector
< pat::MET > > 
metsToken_
 
edm::EDGetTokenT< std::vector
< pat::Muon > > 
musToken_
 
reco::ShallowClonePtrCandidateneutrino_
 
reco::ShallowClonePtrCandidateneutrinoBar_
 
reco::LeafCandidaterecNu
 candidates needed for the genmatch hypothesis More...
 
reco::LeafCandidaterecNuBar
 

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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  genEvtToken_( consumes<TtGenEvent>( edm::InputTag( "genEvt" ) ) )
8 {
9 }
edm::EDGetTokenT< TtGenEvent > genEvtToken_
TtFullLepHypothesis(const edm::ParameterSet &)
default constructor
TtFullLepHypGenMatch::~TtFullLepHypGenMatch ( )

Definition at line 11 of file TtFullLepHypGenMatch.cc.

11 { }

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 14 of file TtFullLepHypGenMatch.cc.

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

21 {
22  // -----------------------------------------------------
23  // add jets
24  // -----------------------------------------------------
25  for(unsigned idx=0; idx<match.size(); ++idx){
26  if( isValid(match[idx], jets) ){
27  switch(idx){
29  setCandidate(jets, match[idx], b_ , jetCorrectionLevel_); break;
31  setCandidate(jets, match[idx], bBar_, jetCorrectionLevel_); break;
32  }
33  }
34  }
35 
36  // -----------------------------------------------------
37  // add leptons
38  // -----------------------------------------------------
39  // get genEvent
41  evt.getByToken(genEvtToken_, genEvt);
42 
43  // push back fake indices if no leptons in genevent
44  if( !genEvt->isFullLeptonic() || !genEvt->lepton() || !genEvt->leptonBar() ){
45  match.push_back( -1 );
46  match.push_back( -1 );
47  match.push_back( -1 );
48  match.push_back( -1 );
49  }
50  else if(genEvt->isFullLeptonic(WDecay::kElec, WDecay::kElec) && elecs->size()>=2){
51  //search indices for electrons
52  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
53  setCandidate(elecs, iLepBar, leptonBar_);
54  match.push_back( iLepBar );
55  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
56  setCandidate(elecs, iLep, lepton_);
57  match.push_back( iLep );
58 
59  // fake indices for muons
60  match.push_back( -1 );
61  match.push_back( -1 );
62  }
63  else if(genEvt->isFullLeptonic(WDecay::kElec, WDecay::kMuon) && !elecs->empty() && !mus->empty() ){
64  if(genEvt->leptonBar()->isElectron()){
65  // push back index for e+
66  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
67  setCandidate(elecs, iLepBar, leptonBar_);
68  match.push_back( iLepBar );
69  // push back fake indices for e- and mu+
70  match.push_back( -1 );
71  match.push_back( -1 );
72  // push back index for mu-
73  int iLep = findMatchingLepton(genEvt->lepton(), mus);
74  setCandidate(mus, iLep, lepton_);
75  match.push_back( iLep );
76  }
77  else{
78  // push back fake index for e+
79  match.push_back( -1 );
80  // push back index for e-
81  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
82  setCandidate(mus, iLepBar, leptonBar_);
83  match.push_back( iLepBar );
84  // push back index for mu+
85  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
86  setCandidate(elecs, iLep, lepton_);
87  match.push_back( iLep );
88  // push back fake index for mu-
89  match.push_back( -1 );
90  }
91  }
92  else if(genEvt->isFullLeptonic(WDecay::kMuon, WDecay::kMuon) && mus->size()>=2 ){
93  // fake indices for electrons
94  match.push_back( -1 );
95  match.push_back( -1 );
96 
97  //search indices for electrons
98  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
99  setCandidate(mus, iLepBar, leptonBar_);
100  match.push_back( iLepBar );
101  int iLep = findMatchingLepton(genEvt->lepton(), mus);
102  setCandidate(mus, iLep, lepton_);
103  match.push_back( iLep );
104  }
105  else{ //this 'else' should happen if at least one genlepton is a tau
106  match.push_back( -1 );
107  match.push_back( -1 );
108  match.push_back( -1 );
109  match.push_back( -1 );
110  }
111 
112  // -----------------------------------------------------
113  // add met and neutrinos
114  // -----------------------------------------------------
115  if( !mets->empty() ){
116  //setCandidate(mets, 0, met_);
117  buildMatchingNeutrinos(evt, mets);
118  }
119 }
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 getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
void buildMatchingNeutrinos(edm::Event &, const edm::Handle< std::vector< pat::MET > > &)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::EDGetTokenT< TtGenEvent > genEvtToken_
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 138 of file TtFullLepHypGenMatch.cc.

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

Referenced by buildHypo().

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

Definition at line 123 of file TtFullLepHypGenMatch.cc.

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

Referenced by buildHypo().

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

Member Data Documentation

edm::EDGetTokenT<TtGenEvent> TtFullLepHypGenMatch::genEvtToken_
protected

Definition at line 35 of file TtFullLepHypGenMatch.h.

Referenced by buildHypo(), and buildMatchingNeutrinos().