ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/dhidas/OSUAnalysis/Tools/interface/ToplikeCandidate.h
Revision: 1.2
Committed: Tue Dec 6 13:56:17 2011 UTC (13 years, 5 months ago) by clseitz
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +47 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #ifndef TOPLIKECANDIDATE_H_
2 #define TOPLIKECANDIDATE_H_
3
4
5 #include <map>
6
7 #include "RecoObjects/MCParticle.h"
8 #include "TopPairEventCandidate.h"
9
10 // using namespace BAT;
11 using namespace std;
12
13 namespace BAT {
14
15
16 namespace ToplikeSelectionSteps { // Note the name space!
17 enum Step { // Any new constant must be added to selStepArr below.
18 // Note this order not important. See selection arrays below.
19 FilterOutScraping,
20 GoodPrimaryvertex,
21 HighLevelTrigger,
22 OneIsolatedElectron,
23 OneIsolatedMuon,
24 LooseMuonVeto,
25 LooseElectronVeto,
26 TightMuonVeto,
27 TightElectronVeto,
28 ConversionRejection,
29 ConversionFinder,
30 MissingTransverseEnergy,
31 HT700GeV,
32 AtLeastOneGoodJet,
33 AtLeastTwoGoodJets,
34 AtLeastThreeGoodJets,
35 AtLeastFourGoodJets,
36 AtLeastFiveGoodJets,
37 FortyfiveGeVElectron,
38 AtLeastOneBtag,
39 AtLeastTwoBtags
40 };
41
42 const std::string StringSteps[] = {
43 "Scraping Filter",
44 "Good primary vertex",
45 "High Level Trigger",
46 "Exactly one isolated electron",
47 "Exactly one isolated muon",
48 "Loose muon veto",
49 "Loose electron veto",
50 "Tight muon veto",
51 "Tight electron veto",
52 "Conversion veto (missing hits)",
53 "Conversion finder (partner track)",
54 "MpT $>$ 20 GeV",
55 "HT (sum pT) $>$ 700 GeV",
56 "$>=$ 1 jets $>$180 GeV",
57 "$>=$ 2 jets $>$90 GeV",
58 "$>=$ 3 jets",
59 "$>=$ 4 jets",
60 "$>=$ 5 jets",
61 "$>$45 GeV electron pT",
62 "$>=$1 SSV b-tag",
63 "$>=$2 SSV b-tags"
64 };
65 }
66
67 typedef struct {
68 ToplikeSelectionSteps::Step key;
69 TTbarEPlusJetsSelection::Step value;
70 } selPair;
71
72 const selPair selStepArr[] = {
73 {ToplikeSelectionSteps::FilterOutScraping, TTbarEPlusJetsSelection::FilterOutScraping},
74 {ToplikeSelectionSteps::HighLevelTrigger, TTbarEPlusJetsSelection::HighLevelTrigger},
75 {ToplikeSelectionSteps::GoodPrimaryvertex, TTbarEPlusJetsSelection::GoodPrimaryvertex},
76 {ToplikeSelectionSteps::OneIsolatedElectron, TTbarEPlusJetsSelection::OneIsolatedElectron},
77 {ToplikeSelectionSteps::LooseMuonVeto, TTbarEPlusJetsSelection::LooseMuonVeto},
78 {ToplikeSelectionSteps::ConversionRejection, TTbarEPlusJetsSelection::ConversionRejection},
79 {ToplikeSelectionSteps::ConversionFinder, TTbarEPlusJetsSelection::ConversionFinder},
80 {ToplikeSelectionSteps::AtLeastOneGoodJet, TTbarEPlusJetsSelection::AtLeastOneGoodJets},
81 {ToplikeSelectionSteps::AtLeastTwoGoodJets, TTbarEPlusJetsSelection::AtLeastTwoGoodJets},
82 {ToplikeSelectionSteps::AtLeastThreeGoodJets, TTbarEPlusJetsSelection::AtLeastThreeGoodJets},
83 {ToplikeSelectionSteps::AtLeastFourGoodJets, TTbarEPlusJetsSelection::AtLeastFourGoodJets},
84 {ToplikeSelectionSteps::AtLeastOneBtag, TTbarEPlusJetsSelection::AtLeastOneBtag},
85 {ToplikeSelectionSteps::AtLeastTwoBtags, TTbarEPlusJetsSelection::AtLeastTwoBtags},
86 {ToplikeSelectionSteps::MissingTransverseEnergy, TTbarEPlusJetsSelection::MissingTransverseEnergy}
87 };
88
89
90 const ToplikeSelectionSteps::Step toplikeElectronSelection[] = {
91 ToplikeSelectionSteps::HighLevelTrigger,
92 ToplikeSelectionSteps::OneIsolatedElectron,
93 ToplikeSelectionSteps::TightMuonVeto,
94 ToplikeSelectionSteps::ConversionRejection,
95 ToplikeSelectionSteps::ConversionFinder,
96 ToplikeSelectionSteps::MissingTransverseEnergy,
97 ToplikeSelectionSteps::HT700GeV,
98 ToplikeSelectionSteps::AtLeastOneGoodJet,
99 ToplikeSelectionSteps::AtLeastTwoGoodJets,
100 ToplikeSelectionSteps::AtLeastOneBtag,
101 ToplikeSelectionSteps::AtLeastThreeGoodJets,
102 ToplikeSelectionSteps::AtLeastFourGoodJets,
103 ToplikeSelectionSteps::AtLeastFiveGoodJets
104 // ToplikeSelectionSteps::AtLeastTwoBtags
105 };
106
107 const unsigned int toplikeElectronSelSize =
108 sizeof(toplikeElectronSelection)/sizeof(ToplikeSelectionSteps::AtLeastOneGoodJet);
109
110 const ToplikeSelectionSteps::Step toplikeMuonSelection[] = {
111 ToplikeSelectionSteps::HighLevelTrigger,
112 ToplikeSelectionSteps::OneIsolatedMuon,
113 ToplikeSelectionSteps::TightElectronVeto,
114 ToplikeSelectionSteps::MissingTransverseEnergy,
115 ToplikeSelectionSteps::HT700GeV,
116 ToplikeSelectionSteps::AtLeastOneGoodJet,
117 ToplikeSelectionSteps::AtLeastTwoGoodJets,
118 ToplikeSelectionSteps::AtLeastOneBtag,
119 ToplikeSelectionSteps::AtLeastThreeGoodJets,
120 ToplikeSelectionSteps::AtLeastFourGoodJets,
121 ToplikeSelectionSteps::AtLeastFiveGoodJets
122 // ToplikeSelectionSteps::AtLeastTwoBtags
123 };
124
125 const unsigned int toplikeMuonSelSize =
126 sizeof(toplikeMuonSelection)/sizeof(ToplikeSelectionSteps::AtLeastOneGoodJet);
127
128 //CS
129 const ToplikeSelectionSteps::Step toplikeMuonSelectionMicro[] = {
130 ToplikeSelectionSteps::HighLevelTrigger,
131 ToplikeSelectionSteps::OneIsolatedMuon,
132 ToplikeSelectionSteps::TightElectronVeto,
133 ToplikeSelectionSteps::MissingTransverseEnergy,
134 ToplikeSelectionSteps::AtLeastOneGoodJet,
135 ToplikeSelectionSteps::AtLeastTwoGoodJets,
136 ToplikeSelectionSteps::AtLeastOneBtag,
137 ToplikeSelectionSteps::AtLeastThreeGoodJets,
138 ToplikeSelectionSteps::AtLeastFourGoodJets,
139 ToplikeSelectionSteps::AtLeastFiveGoodJets
140 // ToplikeSelectionSteps::AtLeastTwoBtags \
141
142 };
143
144 const unsigned int toplikeMuonSelMicroSize =
145 sizeof(toplikeMuonSelectionMicro)/sizeof(ToplikeSelectionSteps::AtLeastOneGoodJet);
146
147 const ToplikeSelectionSteps::Step toplikeElectronSelectionMicro[] = {
148 ToplikeSelectionSteps::HighLevelTrigger,
149 ToplikeSelectionSteps::OneIsolatedElectron,
150 ToplikeSelectionSteps::TightMuonVeto,
151 ToplikeSelectionSteps::ConversionRejection,
152 ToplikeSelectionSteps::ConversionFinder,
153 ToplikeSelectionSteps::MissingTransverseEnergy,
154 ToplikeSelectionSteps::AtLeastOneGoodJet,
155 ToplikeSelectionSteps::AtLeastTwoGoodJets,
156 ToplikeSelectionSteps::AtLeastOneBtag,
157 ToplikeSelectionSteps::AtLeastThreeGoodJets,
158 ToplikeSelectionSteps::AtLeastFourGoodJets,
159 ToplikeSelectionSteps::AtLeastFiveGoodJets
160 // ToplikeSelectionSteps::AtLeastTwoBtags \
161
162 };
163
164 const unsigned int toplikeElectronSelMicroSize =
165 sizeof(toplikeElectronSelectionMicro)/sizeof(ToplikeSelectionSteps::AtLeastOneGoodJet);
166
167
168
169
170
171
172 typedef struct {
173 float deltaR;
174 bool leptonic, hadronic;
175 } topTruth;
176
177 typedef struct {
178 float deltaR;
179 int gpInd;
180 MCParticlePointer ptr;
181 } mcObj;
182
183
184 typedef std::vector< mcObj > mcList;
185
186
187 class ToplikeCandidate : public TopPairEventCandidate {
188
189 protected:
190 // ElectronPointer electronFromW;
191 // JetPointer leptonicBJet, hadronicBJet, jet1FromW, jet2FromW;
192 JetPointer jet3FromW, jet4FromW;
193 ParticlePointer hadronicWtPrime, tPrime;
194 // ParticlePointer neutrino1, neutrino2, leptonicW1, leptonicW2, hadronicW,
195 // leptonicTop1, leptonicTop2, hadronicTop, ttbarResonance;
196 // unsigned short selectedNeutrino, currentSelectedNeutrino, hadronicBIndex,
197 // leptonicBIndex, jet1FromWIndex, jet2FromWIndex;
198 unsigned short jet3FromWIndex, jet4FromWIndex;
199 double ptTprimeSystem, htSystem;
200 bool doneReconstructiontop;
201 mcList getMCList(const Particle *const recoObject) const;
202 mcList getMCListForJets(const Jet *const recoObject) const;
203 bool chkBW(const int ind1, const int ind2, const int ind3) const;
204 bool chkIfChild(int gpInd, int motherGpInd) const;
205 int chkMCMatch(const Particle *const recoObject, int motherInd,
206 const int pdgId, int antiId = 0) const;
207 int chkForQuark(const JetPointer recoObject, const int motherInd,
208 const int badInd = -1) const;
209 int getNumMCMatchesForTop(const ParticlePointer &recoTop,
210 bool hadronic = true) const;
211 int getNumMCPermutsForTop(const ParticlePointer &recoTop,
212 bool hadronic = true) const;
213 // int lTopDauMatching(const mcObj &topTru) const;
214 // int hTopDauMatching(const mcObj &topTru) const;
215 int strictHTopMatching(const mcObj &topTru) const;
216 int strictLTopMatching(const mcObj &topTru) const;
217
218 public:
219 ToplikeCandidate();
220 ToplikeCandidate(const Event& event);
221 virtual ~ToplikeCandidate();
222
223 virtual bool isTopReconstructed(void) const {
224 return doneReconstructiontop;
225 }
226
227 /*
228 const JetPointer getJet3FromHadronicW2() const;
229 const JetPointer getJet4FromHadronicW2() const;
230 const ParticlePointer getHadronicW2() const;
231 const ParticlePointer getTprimeResonance() const;
232 */
233
234 void recoTprimeUsingChi2(ElectronPointer electron);
235 virtual void recoBestSingleTop(LeptonPointer lepton);
236 double TPrimeHTSystem() const;
237 double PtTPrimeSystem() const;
238
239 // Overload the following
240 // virtual const ParticlePointer getResonance() const;
241 bool hasAtLeastFiveGoodJets() const;
242 double tpmass() const;
243 virtual double getGlobalChi2() const;
244 virtual double getLeptonicChi2(double topMass, double unused) const;
245 virtual double getHadronicChi2() const;
246 double getWChi2() const;
247 double sumPt() const;
248 double PtTtbarSystem() const;
249 double PtTtbarSystem(unsigned short neutrinoSolution) const;
250 virtual double getLoneHadChi2() const;
251 topTruth getMCMatches(const ParticlePointer &recoObject) const;
252 int getNumMCMatchesHTop() const;
253 int getNumMCMatchesLTop() const;
254 int getNumCorrectIDLTop() const;
255 int getNumCorrectIDHTop() const;
256 int goodLTopMatching() const;
257 int goodHTopMatching() const;
258 int getTausInJets() const;
259 int numTaus() const;
260 int missRecoJetsForGenJets() const;
261 int missGenJetsForRecoJets() const;
262 };
263
264
265 class TopNoMassConstraint : public ToplikeCandidate {
266 public:
267 TopNoMassConstraint();
268 TopNoMassConstraint(const Event& event);
269 virtual ~TopNoMassConstraint();
270
271 virtual double getLoneHadChi2() const;
272 virtual double getLepBAngle() const;
273 };
274
275
276 class TopPlusXCandidates : public ToplikeCandidate {
277 public:
278
279 static const JetPointer nulljet;
280
281 TopPlusXCandidates();
282 TopPlusXCandidates(const Event& event);
283 virtual ~TopPlusXCandidates();
284
285 virtual void recoBestLeptoTop(LeptonPointer lepton,
286 const JetPointer jet = nulljet, const JetPointer wJet1 = nulljet,
287 const JetPointer wJet2 = nulljet);
288 virtual void recoHadronicTop(LeptonPointer lepton,
289 const JetPointer jet = nulljet);
290 virtual void findDJet(const JetPointer topJet = nulljet);
291 virtual bool passesSelectionStep(enum
292 ToplikeSelectionSteps::Step step) const;
293 virtual bool passesSelectionStepUpTo(unsigned int step,
294 const ToplikeSelectionSteps::Step steps[]) const;
295 virtual bool passesFullEPlusJetSelection() const;
296 virtual bool passesFullEPlusJetSelectionKK() const;
297 virtual bool passesFullMuPlusJetSelection() const;
298 //CS
299 virtual bool passesFullEPlusJetSelectionMicro() const;
300 virtual bool passesFullMuPlusJetSelectionMicro() const;
301
302 virtual bool passesMETCut() const;
303 virtual bool passesHTCut() const;
304 virtual bool passesExtraElectronCut() const;
305 virtual bool hasOnlyOneGoodIsolatedMuon() const;
306 virtual bool hasNoIsolatedElectron() const;
307 virtual bool hasNoGoodIsolatedElectron() const;
308 virtual bool hasNoGoodIsolatedMuon() const;
309 virtual bool hasAtLeastOneGoodJet() const;
310 virtual bool hasAtLeastTwoGoodJets() const;
311
312 virtual double jetsHTNoTop(unsigned int numJets = 3) const;
313 virtual double ST() const;
314 virtual double getTopMetAngle() const;
315 virtual JetPointer leadnontopjet() const;
316 virtual double mass2jets(unsigned int jet1, unsigned int jet2) const;
317 virtual double mass4jets() const;
318
319 // The templates below are no longer necessary because there is now a
320 // LeptonPointer, but they still work, so leave them as-is.
321
322 // Template functions must be defined here to be instantiated in other files.
323 template <class PartPtr> double transMass4j(const PartPtr leptonPtr) const {
324 double px = leptonPtr->px() + met->px();
325 double py = leptonPtr->py() + met->py();
326 double pz = 0.0;
327 double et = leptonPtr->et() + met->et();
328 for (unsigned short jetIndex = 0; jetIndex < 4 && jetIndex < goodJets.size(); ++jetIndex) {
329 px += goodJets.at(jetIndex)->px();
330 py += goodJets.at(jetIndex)->py();
331 et += goodJets.at(jetIndex)->et();
332 }
333 Particle mt(et, px, py, pz);
334 return (mt.mass());
335 }
336
337 template <class PartPtr> double transMass2j(const PartPtr leptonPtr) const {
338 double px = leptonPtr->px() + met->px();
339 double py = leptonPtr->py() + met->py();
340 double pz = 0.0;
341 double et = leptonPtr->et() + met->et();
342 if (goodBJets.size() > 0) {
343 px += goodBJets.front()->px();
344 py += goodBJets.front()->py();
345 et += goodBJets.front()->et();
346 }
347 for (unsigned short jetIndex = 0; jetIndex < 2 && jetIndex < goodJets.size(); ++jetIndex) {
348 if (goodBJets.size() <= 0 || goodJets.at(jetIndex) != goodBJets.front()) {
349 px += goodJets.at(jetIndex)->px();
350 py += goodJets.at(jetIndex)->py();
351 et += goodJets.at(jetIndex)->et();
352 jetIndex = 2; // Terminate loop.
353 }
354 }
355 Particle mt(et, px, py, pz);
356 return (mt.mass());
357 }
358
359
360 template <class PartPtr> const ParticlePointer transMasslm1b(const PartPtr leptonPtr) const {
361 double px = leptonPtr->px() + met->px();
362 double py = leptonPtr->py() + met->py();
363 double pz = 0.0;
364 double et = leptonPtr->et() + met->et();
365 if (goodBJets.size() > 0) {
366 px += goodBJets.front()->px();
367 py += goodBJets.front()->py();
368 et += goodBJets.front()->et();
369 }
370 return (ParticlePointer(new Particle(et, px, py, pz)));
371 }
372
373
374 template <class PartPtr> const ParticlePointer massl1b(const PartPtr leptonPtr) const {
375 double px = leptonPtr->px();
376 double py = leptonPtr->py();
377 double pz = 0.0;
378 double et = leptonPtr->et();
379 if (goodBJets.size() > 0) {
380 px += goodBJets.front()->px();
381 py += goodBJets.front()->py();
382 et += goodBJets.front()->et();
383 }
384 return (ParticlePointer(new Particle(et, px, py, pz)));
385 }
386
387
388 template <class PartPtr> double deltaPhiTops(const PartPtr leptonPtr) const {
389 double px = 0.0, py = 0.0, pz = 0.0, et = 0.0;
390 for (unsigned short jetIndex = 1; jetIndex < 4 && jetIndex < goodJets.size(); ++jetIndex) {
391 px += goodJets.at(jetIndex)->px();
392 py += goodJets.at(jetIndex)->py();
393 et += goodJets.at(jetIndex)->et();
394 }
395 ParticlePointer mt = ParticlePointer(new Particle(et, px, py, pz));
396 return (transMasslm1b(leptonPtr)->deltaPhi(mt));
397 }
398
399
400 template <class PartPtr> double deltaPhiLepJet(const PartPtr leptonPtr) const {
401 if (goodJets.size() > 0)
402 return (leptonPtr->deltaPhi(goodJets.front()));
403 return (0.0);
404 }
405
406
407 JetPointer dJetFromWp;
408 short dJetFromWpIndex;
409 };
410
411
412 class TwoNonResTops : public TopPlusXCandidates {
413 public:
414 TwoNonResTops();
415 TwoNonResTops(const Event& event);
416 virtual ~TwoNonResTops();
417
418 void recoNonResTops(LeptonPointer lepton);
419 void recoNonResTopsWdjet(LeptonPointer lepton);
420 void recoWpFrom1Top(LeptonPointer lepton);
421 virtual double getGlobalChi2() const;
422 virtual const JetPointer getLtNonTopJet() const;
423 virtual const ParticlePointer getWprime() const;
424 virtual const ParticlePointer getBtBWprime() const;
425 virtual const ParticlePointer getNegWprime() const;
426 virtual const ParticlePointer getNegWprimeBad() const;
427 virtual double getHadTopDAngle() const;
428 virtual void getTrueWpChain();
429 virtual MCParticlePointer getWpTru() const;
430 virtual MCParticlePointer getWpTopTru() const;
431 virtual MCParticlePointer getSpecTop() const;
432 virtual MCParticlePointer getWpTopBTru() const;
433 virtual MCParticlePointer getSpecTopB() const;
434 virtual MCParticlePointer getWpDDauTru() const;
435 virtual double getTotalChi2DJ(unsigned short neutrinoSolution) const;
436
437 template <class PartPtr> double deltaPhiLepDJet(const PartPtr leptonPtr) const {
438 if (goodJets.size() > 4)
439 return (leptonPtr->deltaPhi(getLtNonTopJet()));
440 return (0.0);
441 }
442
443 ParticlePointer wpFrom1Top, wpBadFrom1Top;
444
445 protected:
446 MCParticlePointer wpTru, wpTopTru, specTopTru, wpDDauTru;
447 MCParticlePointer wpTopBTru, specTopBTru;
448 bool wpGenParticlesSet;
449 ParticlePointer topFromWp;
450 };
451
452
453 class LeptoTopNoMassConstraint : public TopNoMassConstraint {
454 public:
455 LeptoTopNoMassConstraint();
456 LeptoTopNoMassConstraint(const Event& event);
457 virtual ~LeptoTopNoMassConstraint();
458
459 // virtual bool passesFullEPlusJetSelection() const;
460 virtual void inspectReconstructedEvent() const;
461
462 };
463
464 }
465
466 #endif /* TOPLIKECANDIDATE_H_ */