Fork me on GitHub

source: git/python/TopReconstruction.py@ 621f6a3

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 621f6a3 was ae1d49f, checked in by pavel <pavel@…>, 12 years ago

add DelphesAnalysis

  • Property mode set to 100644
File size: 1.8 KB
Line 
1from itertools import combinations
2
3def jetSelection(event, ptcut=20., etacut=2.4):
4 def jetfilter(jet): return jet.PT>ptcut and abs(jet.Eta)<etacut
5 return filter(jetfilter,event.jets)
6
7def bjets(event):
8 def jetfilter(jet): return jet.BTag
9 return filter(jetfilter,event.selectedJets)
10
11def ljets(event):
12 def jetfilter(jet): return jet.BTag==0
13 return filter(jetfilter,event.selectedJets)
14
15def topCandidates(event,leptonic=True,hadronic=True):
16 electrons = event.electrons
17 muons = event.muons
18 ljets = event.lJets
19 bjets = event.bJets
20 met = event.MEt[0]
21 output = []
22 # leptonic top candidates: lepton + bjet + MET
23 if leptonic and not hadronic:
24 # build all combinations
25 for b in bjets:
26 for l in electrons:
27 output.append( (l,b,met) )
28 for l in muons:
29 output.append( (l,b,met) )
30 # no specific order
31 return output
32 # hadronic top candidates: 2 jets + bjet
33 if hadronic and not leptonic:
34 # build all combinations
35 for j in combinations(ljets,2):
36 for b in bjets:
37 output.append( (j[0], j[1], b) )
38 # order by distance to top mass
39 def massDistance(top):
40 mass = (top[0].P4()+top[1].P4()+top[2].P4()).M()
41 return abs(mass-172.9)
42 return sorted(output,key=massDistance)
43 # full event reconstruction
44 if hadronic and leptonic:
45 # build all combinations
46 for j in combinations(ljets,2):
47 for b in combinations(bjets,2):
48 for l in electrons:
49 output.append( (j[0], j[1], b[0], l, b[1], met) )
50 for l in muons:
51 output.append( (j[0], j[1], b[0], l, b[1], met) )
52 # find the best ones: order via hadronic top mass
53 def massDistance(top):
54 mass = (top[0].P4()+top[1].P4()+top[2].P4()).M()
55 return abs(mass-172.9)
56 return sorted(output,key=massDistance)
57
Note: See TracBrowser for help on using the repository browser.