test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TtDilepLRSignalSelObservables.cc
Go to the documentation of this file.
7 
8 /************** Definition of the functions of the class ***************/
9 
10 //Constructor
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 }
18 
19 // Destructor
21 }
22 
23 std::vector< TtDilepLRSignalSelObservables::IntBoolPair >
25  const edm::Event & iEvent, bool matchOnly)
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 }
192 
194  (double v1, double v2, int obsNbr, std::vector< IntDblPair > & varList,
195  bool match1, bool match2, std::vector< IntBoolPair > & matchList)
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 }
210 
211 double TtDilepLRSignalSelObservables::delta(double phi1, double phi2)
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 }
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:434
std::pair< unsigned int, bool > IntBoolPair
const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: Particle.cc:86
std::vector< IntBoolPair > operator()(TtDilepEvtSolution &, const edm::Event &iEvent, bool matchOnly=false)
std::string getWmDecay() const
std::string getWpDecay() const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
int iEvent
Definition: GenABIO.cc:230
Class derived from the TopGenEvent for ttbar events.
Definition: TtGenEvent.h:18
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
TtDilepLRSignalSelObservables(edm::ConsumesCollector &&iC, const edm::EDGetTokenT< std::vector< pat::Jet > > &jetSourceToken)
reco::Particle getLeptPos() const
bool isValid() const
Definition: HandleBase.h:76
#define M_PI
int partonFlavour() const
return the parton-based flavour of the jet
Definition: Jet.cc:221
std::vector< IntBoolPair > evtselectVarMatch
bool failedToGet() const
Definition: HandleBase.h:80
pat::Jet getJetB() const
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
pat::Jet getCalJetB() const
const reco::GenParticle * getGenLepp() const
genEvtToken_(mayConsume< TtGenEvent >(genEvt_))
virtual const LorentzVector & p4() const
four-momentum Lorentz vector