48 def makeAlgs(self, config):
49 if config.dataType() is DataType.Data: return
50
51 alg = config.createAlgorithm('CP::LeptonSFCalculatorAlg',
52 'leptonSFCalculator')
53
54 if self.electrons:
55 electrons, electronSelection = config.readNameAndSelection(self.electrons)
56 alg.electrons = electrons
57 alg.electronSelection = electronSelection
58 if self.electronSFs:
59 alg.electronSFs = self.electronSFs
60 else:
61 if '.' not in self.electrons:
62 raise ValueError(f'electrons={self.electrons} has no selection: either use the format `container.selection` or set electronSFs explicitly.')
63 alg.electronSFs = [ f'el_reco_effSF_{self.electrons.split(".")[1]}_%SYS%',
64 f'el_id_effSF_{self.electrons.split(".")[1]}_%SYS%' ]
65 if 'isolated' in alg.electronSelection:
66 alg.electronSFs += [ f'el_isol_effSF_{self.electrons.split(".")[1]}_%SYS%' ]
67 if 'chargeID' in alg.electronSelection:
68 alg.electronSFs += [ f'el_ecids_effSF_{self.electrons.split(".")[1]}_%SYS%' ]
69 if self.includeElectronChargeMisID:
70 alg.electronSFs += [ f'el_charge_misid_effSF_{self.electrons.split(".")[1]}_%SYS%' ]
71
72 if self.muons:
73 muons, muonSelection = config.readNameAndSelection(self.muons)
74 alg.muons = muons
75 alg.muonSelection = muonSelection
76 if self.muonSFs:
77 alg.muonSFs = self.muonSFs
78 else:
79 if '.' not in self.muons:
80 raise ValueError(f'muons={self.muons} has no selection: either use the format `container.selection` or set muonSFs explicitly.')
81 alg.muonSFs = [ f'muon_reco_effSF_{self.muons.split(".")[1]}_%SYS%']
82 if 'trackSelection' in alg.muonSelection:
83 alg.muonSFs += [ f'muon_TTVA_effSF_{self.muons.split(".")[1]}_%SYS%' ]
84 if 'isolated' in alg.muonSelection:
85 alg.muonSFs += [ f'muon_isol_effSF_{self.muons.split(".")[1]}_%SYS%' ]
86 if self.includeMuonBadVeto:
87 alg.muonSFs += [ f'muon_BadMuonVeto_effSF_{self.muons.split(".")[1]}_%SYS%' ]
88
89 if self.photons:
90 photons, photonSelection = config.readNameAndSelection(self.photons)
91 alg.photons = photons
92 alg.photonSelection = photonSelection
93 if self.photonSFs:
94 alg.photonSFs = self.photonSFs
95 else:
96 if '.' not in self.photons:
97 raise ValueError(f'photons={self.photons} has no selection: either use the format `container.selection` or set photonSFs explicitly.')
98 alg.photonSFs = [ f'ph_id_effSF_{self.photons.split(".")[1]}_%SYS%' ]
99 if 'isolated' in alg.photonSelection:
100 alg.photonSFs += [ f'ph_isol_effSF_{self.photons.split(".")[1]}_%SYS%' ]
101
102 if self.taus:
103 taus, tauSelection = config.readNameAndSelection(self.taus)
104 alg.taus = taus
105 alg.tauSelection = tauSelection
106 if self.tauSFs:
107 alg.tauSFs = self.tauSFs
108 else:
109 if '.' not in self.taus:
110 raise ValueError(f'taus={self.taus} has no selection: either use the format `container.selection` or set tauSFs explicitly.')
111 alg.tauSFs = [ f'tau_Reco_effSF_{self.taus.split(".")[1]}_%SYS%',
112 f'tau_ID_effSF_{self.taus.split(".")[1]}_%SYS%']
113 if 'eVeto' in alg.tauSelection:
114 alg.tauSFs += [ f'tau_EvetoFakeTau_effSF_{self.taus.split(".")[1]}_%SYS%',
115 f'tau_EvetoTrueTau_effSF_{self.taus.split(".")[1]}_%SYS%']
116
117 alg.event_leptonSF = f'leptonSF_{self.lepton_postfix}_%SYS%'
118
119 config.addOutputVar('EventInfo', alg.event_leptonSF, f'weight_leptonSF_{self.lepton_postfix}')