-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathworkflow.py
More file actions
70 lines (60 loc) · 2.59 KB
/
workflow.py
File metadata and controls
70 lines (60 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import awkward as ak
from pocket_coffea.workflows.base import BaseProcessorABC
from pocket_coffea.utils.configurator import Configurator
from pocket_coffea.lib.hist_manager import Axis
from pocket_coffea.lib.objects import (
lepton_selection,
jet_selection,
btagging,
get_dilepton,
)
class ZmumuBaseProcessor(BaseProcessorABC):
def __init__(self, cfg: Configurator):
super().__init__(cfg)
def apply_object_preselection(self, variation):
'''
The ttHbb processor cleans
- Electrons
- Muons
- Jets -> JetGood
- BJet -> BJetGood
'''
# Include the supercluster pseudorapidity variable
electron_etaSC = self.events.Electron.eta + self.events.Electron.deltaEtaSC
self.events["Electron"] = ak.with_field(
self.events.Electron, electron_etaSC, "etaSC"
)
# Build masks for selection of muons, electrons, jets, fatjets
self.events["MuonGood"] = lepton_selection(
self.events, "Muon", self.params
)
self.events["ElectronGood"] = lepton_selection(
self.events, "Electron", self.params
)
leptons = ak.with_name(
ak.concatenate((self.events.MuonGood, self.events.ElectronGood), axis=1),
name='PtEtaPhiMCandidate',
)
self.events["LeptonGood"] = leptons[ak.argsort(leptons.pt, ascending=False)]
self.events["JetGood"], self.jetGoodMask = jet_selection(
self.events, "Jet", self.params,
self._year,
leptons_collection="LeptonGood"
)
self.events["BJetGood"] = btagging(
self.events["JetGood"], self.params.btagging.working_point[self._year], wp=self.params.object_preselection.Jet.btag.wp)
self.events["ll"] = get_dilepton(
self.events.ElectronGood, self.events.MuonGood
)
def count_objects(self, variation):
self.events["nMuonGood"] = ak.num(self.events.MuonGood)
self.events["nElectronGood"] = ak.num(self.events.ElectronGood)
self.events["nLeptonGood"] = (
self.events["nMuonGood"] + self.events["nElectronGood"]
)
self.events["nJetGood"] = ak.num(self.events.JetGood)
self.events["nBJetGood"] = ak.num(self.events.BJetGood)
# self.events["nfatjet"] = ak.num(self.events.FatJetGood)
# Function that defines common variables employed in analyses and save them as attributes of `events`
def define_common_variables_before_presel(self, variation):
self.events["JetGood_Ht"] = ak.sum(abs(self.events.JetGood.pt), axis=1)