CMS 3D CMS Logo

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

#include <TtDilepLRSignalSelObservables.h>

Public Types

typedef std::pair< unsigned
int, bool > 
IntBoolPair
 

Public Member Functions

std::vector< IntBoolPairoperator() (TtDilepEvtSolution &, const edm::Event &iEvent, bool matchOnly=false)
 
 TtDilepLRSignalSelObservables (edm::ConsumesCollector &&iC, const edm::EDGetTokenT< std::vector< pat::Jet > > &jetSourceToken)
 
 ~TtDilepLRSignalSelObservables ()
 

Private Types

typedef std::pair< unsigned
int, double > 
IntDblPair
 

Private Member Functions

double delta (double phi1, double phi2)
 
void fillMinMax (double v1, double v2, int obsNbr, std::vector< IntDblPair > &varList, bool match1, bool match2, std::vector< IntBoolPair > &matchList)
 

Private Attributes

int count1
 
int count2
 
int count3
 
int count4
 
int count5
 
std::vector< IntBoolPairevtselectVarMatch
 
std::vector< IntDblPairevtselectVarVal
 
edm::EDGetTokenT< TtGenEventgenEvtToken_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetSourceToken_
 

Detailed Description

Definition at line 16 of file TtDilepLRSignalSelObservables.h.

Member Typedef Documentation

typedef std::pair<unsigned int,bool> TtDilepLRSignalSelObservables::IntBoolPair

Definition at line 23 of file TtDilepLRSignalSelObservables.h.

typedef std::pair<unsigned int,double> TtDilepLRSignalSelObservables::IntDblPair
private

Definition at line 29 of file TtDilepLRSignalSelObservables.h.

Constructor & Destructor Documentation

TtDilepLRSignalSelObservables::TtDilepLRSignalSelObservables ( edm::ConsumesCollector &&  iC,
const edm::EDGetTokenT< std::vector< pat::Jet > > &  jetSourceToken 
)

Definition at line 11 of file TtDilepLRSignalSelObservables.cc.

References count1, count2, count3, count4, and count5.

12 : jetSourceToken_( jetSourceToken )
13 , genEvtToken_( iC.consumes<TtGenEvent>( edm::InputTag( "genEvt" ) ) )
14 {
15 count1=0; count2=0; count3=0;
16 count4=0; count5=0; count3=0;
17 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Class derived from the TopGenEvent for ttbar events.
Definition: TtGenEvent.h:18
edm::EDGetTokenT< TtGenEvent > genEvtToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
TtDilepLRSignalSelObservables::~TtDilepLRSignalSelObservables ( )

Definition at line 20 of file TtDilepLRSignalSelObservables.cc.

20  {
21 }

Member Function Documentation

double TtDilepLRSignalSelObservables::delta ( double  phi1,
double  phi2 
)
private

Definition at line 211 of file TtDilepLRSignalSelObservables.cc.

References SiPixelRawToDigiRegional_cfi::deltaPhi, and M_PI.

Referenced by operator()().

212 {
213  double deltaPhi = phi1 - phi2;
214  while (deltaPhi > M_PI) deltaPhi -= 2*M_PI;
215  while (deltaPhi <= -M_PI) deltaPhi += 2*M_PI;
216  return deltaPhi;
217 }
#define M_PI
void TtDilepLRSignalSelObservables::fillMinMax ( double  v1,
double  v2,
int  obsNbr,
std::vector< IntDblPair > &  varList,
bool  match1,
bool  match2,
std::vector< IntBoolPair > &  matchList 
)
private

Definition at line 194 of file TtDilepLRSignalSelObservables.cc.

Referenced by operator()().

196 {
197  if (v1<v2) {
198  varList.push_back(IntDblPair(obsNbr, v1));
199  varList.push_back(IntDblPair(obsNbr+1, v2));
200  matchList.push_back(IntBoolPair(obsNbr, match1));
201  matchList.push_back(IntBoolPair(obsNbr+1, match2));
202 
203  } else {
204  varList.push_back(IntDblPair(obsNbr, v2));
205  varList.push_back(IntDblPair(obsNbr+1, v1));
206  matchList.push_back(IntBoolPair(obsNbr, match2));
207  matchList.push_back(IntBoolPair(obsNbr+1, match1));
208  }
209 }
std::pair< unsigned int, bool > IntBoolPair
std::pair< unsigned int, double > IntDblPair
std::vector< TtDilepLRSignalSelObservables::IntBoolPair > TtDilepLRSignalSelObservables::operator() ( TtDilepEvtSolution solution,
const edm::Event iEvent,
bool  matchOnly = false 
)

Definition at line 24 of file TtDilepLRSignalSelObservables.cc.

References funct::abs(), count1, count2, count3, count4, count5, delta(), SiPixelRawToDigiRegional_cfi::deltaPhi, reco::LeafCandidate::et(), evtselectVarMatch, evtselectVarVal, edm::HandleBase::failedToGet(), fillMinMax(), MCTruth::genEvent, genEvtToken_, edm::Event::getByToken(), TtDilepEvtSolution::getCalJetB(), TtDilepEvtSolution::getCalJetBbar(), TtDilepEvtSolution::getGenLepm(), TtDilepEvtSolution::getGenLepp(), TtDilepEvtSolution::getJetB(), TtDilepEvtSolution::getJetBbar(), TtDilepEvtSolution::getLeptNeg(), TtDilepEvtSolution::getLeptPos(), TtDilepEvtSolution::getWmDecay(), TtDilepEvtSolution::getWpDecay(), i, edm::HandleBase::isValid(), fwrapper::jets, jetSourceToken_, M_PI, reco::Particle::p4(), reco::LeafCandidate::p4(), pat::Jet::partonFlavour(), reco::LeafCandidate::pdgId(), createTree::pp, and TtDilepEvtSolution::setLRSignalEvtObservables().

26 {
27  evtselectVarVal.clear();
28  evtselectVarMatch.clear();
29 
30  // Check whether the objects are matched:
31  bool matchB1 = false;
32  bool matchB2 = false;
33  bool matchB = false;
34  bool matchBbar = false;
35  bool matchLeptPos = false;
36  bool matchLeptNeg = false;
37 
39  iEvent.getByToken(genEvtToken_,genEvent);
40 
41  if (!genEvent.failedToGet() && genEvent.isValid()) {
42  // std::cout <<std::endl;
43  double dr, dr1, dr2;
44 
45  if (genEvent->isFullLeptonic()) {
46  // Match the leptons, by type and deltaR
47  dr = DeltaR<reco::Particle, reco::GenParticle>()(solution.getLeptPos(), *(solution.getGenLepp()));
48  matchLeptPos = (
49  ( ((solution.getWpDecay()=="electron")&&(std::abs(solution.getGenLepp()->pdgId())==11))
50  || ((solution.getWpDecay()=="muon")&&(std::abs(solution.getGenLepp()->pdgId())==13)) )
51  && (dr < 0.1) );
52 
53  dr = DeltaR<reco::Particle, reco::GenParticle>()(solution.getLeptNeg(), *(solution.getGenLepm()));
54  matchLeptNeg = (
55  ( ((solution.getWmDecay()=="electron")&&(std::abs(solution.getGenLepm()->pdgId())==11))
56  || ((solution.getWmDecay()=="muon")&&(std::abs(solution.getGenLepm()->pdgId())==13)) )
57  && (dr < 0.1) );
58  }
59 
60  if (genEvent->isSemiLeptonic()) {
61  int id = genEvent->singleLepton()->pdgId();
62 
63  if (id>0) {
64  dr = DeltaR<reco::Particle, reco::GenParticle>()(solution.getLeptNeg(), *(genEvent->singleLepton()));
65  matchLeptNeg = (
66  ( ((solution.getWmDecay()=="electron") && (id==11))
67  || ((solution.getWmDecay()=="muon") && (id==13)) )
68  && (dr < 0.1) );
69  } else {
70  dr = DeltaR<reco::Particle, reco::GenParticle>()(solution.getLeptPos(), *(genEvent->singleLepton()));
71  matchLeptPos = (
72  ( ((solution.getWpDecay()=="electron")&& (id==-11))
73  || ((solution.getWpDecay()=="muon") && (id==-13)) )
74  && (dr < 0.1) );
75  }
76  }
77 
78  if (genEvent->isTtBar() && genEvent->numberOfBQuarks()>1) {
79  if (solution.getJetB().partonFlavour()==5) ++count1;
80  if (solution.getJetBbar().partonFlavour()==5) ++count1;
81 
82  dr1 = DeltaR<pat::Jet, reco::GenParticle>()(solution.getCalJetB(), *(genEvent->b()));
83  dr2 = DeltaR<pat::Jet, reco::GenParticle>()(solution.getCalJetB(), *(genEvent->bBar()));
84 
85  matchB1= ( (dr1<0.4) || (dr2<0.4));
86  matchB = ( (solution.getJetB().partonFlavour()==5) && (dr1<0.4) );
87  if (matchB) ++count3;
88  matchB = ( (dr1<0.4) );
89  if (dr1<0.5) ++count2;
90  if (dr1<0.4) ++count4;
91  if (dr1<0.3) ++count5;
92 
93  dr1 = DeltaR<pat::Jet, reco::GenParticle>()(solution.getCalJetBbar(), *(genEvent->b()));
94  dr2 = DeltaR<pat::Jet, reco::GenParticle>()(solution.getCalJetBbar(), *(genEvent->bBar()));
95 
96  matchBbar = ( (solution.getJetBbar().partonFlavour()==5) && (dr2<0.4) );
97  if (matchBbar) ++count3;
98  matchBbar = ( (dr2<0.4) );
99  matchB2 = ( (dr1<0.4) || (dr2<0.4));
100  if (dr2<0.5) ++count2;
101  if (dr2<0.4) ++count4;
102  if (dr2<0.3) ++count5;
103  }
104 
105  }
106 
108  iEvent.getByToken(jetSourceToken_, jets);
109 
110  // Lower / Higher of both jet angles
111 
112  double v1 = std::abs( solution.getJetB().p4().theta() - M_PI/2 );
113  double v2 = std::abs( solution.getJetBbar().p4().theta() - M_PI/2 ) ;
114  fillMinMax(v1, v2, 1, evtselectVarVal, matchB1, matchB2, evtselectVarMatch);
115 
116  // Lower / Higher of both jet pT
117 
118  double pt1 = solution.getJetB().p4().pt();
119  double pt2 = solution.getJetBbar().p4().pt();
120  fillMinMax(pt1, pt2, 3, evtselectVarVal, matchB1, matchB2, evtselectVarMatch);
121 
122  // Lower / Higher of both lepton pT
123 
124  pt1 = solution.getLeptPos().p4().pt();
125  pt2 = solution.getLeptNeg().p4().pt();
126  fillMinMax(pt1, pt2, 5, evtselectVarVal, matchLeptPos, matchLeptNeg, evtselectVarMatch);
127 
128  // delta theta btw the b-jets
129 
130  double deltaPhi = std::abs( delta(solution.getJetB().p4().phi(),
131  solution.getJetBbar().p4().phi()) );
132 
133  evtselectVarVal.push_back(IntDblPair(7, deltaPhi));
134  evtselectVarMatch.push_back(IntBoolPair(7, matchB1&&matchB2));
135 
136  // delta phi btw the b-jets
137 
138  double deltaTheta = std::abs( delta (solution.getJetBbar().p4().theta(),
139  solution.getJetB().p4().theta() ) );
140 
141  evtselectVarVal.push_back(IntDblPair(8, deltaTheta));
142  evtselectVarMatch.push_back(IntBoolPair(8, matchB1&&matchB2));
143 
144  // Lower / Higher of phi difference between the b and associated lepton
145 
146  double deltaPhi1 = std::abs ( delta( solution.getJetB().p4().phi(),
147  solution.getLeptPos().p4().phi() ) );
148  double deltaPhi2 = std::abs ( delta( solution.getJetBbar().p4().phi(),
149  solution.getLeptNeg().p4().phi() ) );
150 
151  fillMinMax(deltaPhi1, deltaPhi2, 9, evtselectVarVal,
152  matchB&&matchLeptPos, matchBbar&&matchLeptNeg, evtselectVarMatch);
153 
154  // Lower / Higher of theta difference between the b and associated lepton
155 
156  double deltaTheta1 = std::abs( solution.getJetB().p4().theta() -
157  solution.getLeptPos().p4().theta() );
158  double deltaTheta2 = std::abs( solution.getJetBbar().p4().theta() -
159  solution.getLeptNeg().p4().theta() );
160  fillMinMax(deltaTheta1, deltaTheta2, 11, evtselectVarVal,
161  matchB&&matchLeptPos, matchBbar&&matchLeptNeg, evtselectVarMatch);
162 
163  // Invariant Mass of lepton pair
164 
165  math::XYZTLorentzVector pp = solution.getLeptPos().p4() + solution.getLeptNeg().p4();
166  double mass = pp.mass();
167  evtselectVarVal.push_back(IntDblPair(13, mass));
168  evtselectVarMatch.push_back(IntBoolPair(13, matchLeptNeg&&matchLeptPos));
169 
170  evtselectVarVal.push_back(IntDblPair(13, mass));
171  evtselectVarMatch.push_back(IntBoolPair(13, matchLeptNeg&&matchLeptPos));
172 
173  std::vector <pat::Jet> jet3;
174  for (int i=0;i<(int)jets->size();++i) {
175 if ( ((*jets)[i].et()<solution.getJetB().et()) && ((*jets)[i].et()<solution.getJetBbar().et())) {jet3.push_back((*jets)[i]);
176 }}
177  double jet1Ratio = 0., jet2Ratio = 0.;
178  if (jet3.size()>0) {
179  jet1Ratio = jet3[0].et()/solution.getJetB().et();
180  jet2Ratio = jet3[0].et()/solution.getJetBbar().et();
181  }
182  fillMinMax(jet1Ratio, jet2Ratio, 14, evtselectVarVal,
183  matchB1, matchB2, evtselectVarMatch);
184 
185  evtselectVarVal.push_back(IntDblPair(16, jets->size()));
186  evtselectVarMatch.push_back(IntBoolPair(16, matchB&&matchBbar));
187 
188 
189  if (!matchOnly) solution.setLRSignalEvtObservables(evtselectVarVal);
190  return evtselectVarMatch;
191 }
pat::Jet getCalJetBbar() const
const reco::GenParticle * getGenLepm() const
double delta(double phi1, double phi2)
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
tuple pp
Definition: createTree.py:15
virtual double et() const
transverse energy
void fillMinMax(double v1, double v2, int obsNbr, std::vector< IntDblPair > &varList, bool match1, bool match2, std::vector< IntBoolPair > &matchList)
Definition: deltaR.h:79
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::pair< unsigned int, bool > IntBoolPair
const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: Particle.h:72
std::string getWmDecay() const
std::string getWpDecay() const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void setLRSignalEvtObservables(const std::vector< std::pair< unsigned int, double > > &)
std::pair< unsigned int, double > IntDblPair
reco::Particle getLeptNeg() const
vector< PseudoJet > jets
pat::Jet getJetBbar() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< TtGenEvent > genEvtToken_
tuple genEvent
Definition: MCTruth.py:33
int partonFlavour() const
return the parton-based flavour of the jet
reco::Particle getLeptPos() const
bool isValid() const
Definition: HandleBase.h:75
#define M_PI
std::vector< IntBoolPair > evtselectVarMatch
bool failedToGet() const
Definition: HandleBase.h:79
pat::Jet getJetB() const
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
pat::Jet getCalJetB() const
const reco::GenParticle * getGenLepp() const
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99

Member Data Documentation

int TtDilepLRSignalSelObservables::count1
private

Definition at line 41 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()(), and TtDilepLRSignalSelObservables().

int TtDilepLRSignalSelObservables::count2
private

Definition at line 41 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()(), and TtDilepLRSignalSelObservables().

int TtDilepLRSignalSelObservables::count3
private

Definition at line 41 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()(), and TtDilepLRSignalSelObservables().

int TtDilepLRSignalSelObservables::count4
private

Definition at line 41 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()(), and TtDilepLRSignalSelObservables().

int TtDilepLRSignalSelObservables::count5
private

Definition at line 41 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()(), and TtDilepLRSignalSelObservables().

std::vector< IntBoolPair > TtDilepLRSignalSelObservables::evtselectVarMatch
private

Definition at line 40 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()().

std::vector< IntDblPair > TtDilepLRSignalSelObservables::evtselectVarVal
private

Definition at line 39 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()().

edm::EDGetTokenT<TtGenEvent> TtDilepLRSignalSelObservables::genEvtToken_
private

Definition at line 37 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()().

edm::EDGetTokenT<std::vector<pat::Jet> > TtDilepLRSignalSelObservables::jetSourceToken_
private

Definition at line 36 of file TtDilepLRSignalSelObservables.h.

Referenced by operator()().