107 def makeAlgs (self, config) :
109 if self.selectionName
is not None:
110 selectionName = self.selectionName
111 outputLabel = self.outputLabel +
'_' + selectionName
112 inputLabel = self.inputLabel +
'_' + selectionName
113 select_or_decoration =
'select_or_' + self.selectionName
114 postfix =
'_' + self.selectionName
116 if self.addToAllSelections:
118 select_or_decoration =
'select_or'
120 selectionName = self.outputLabel
121 select_or_decoration =
'select_' + self.outputLabel
122 outputLabel = self.outputLabel
123 inputLabel = self.inputLabel
124 postfix = self.outputLabel
131 if self.jetsSelectionName
is not None:
132 jetsSelectionName = self.jetsSelectionName
134 if len(self.jets.
split(
".")) == 2
and not self.addToAllSelections:
135 jetsSelectionName = self.jets.
split(
".")[1]
137 jetsSelectionName = selectionName
138 if self.fatJetsSelectionName
is not None:
139 fatJetsSelectionName = self.fatJetsSelectionName
141 if len(self.fatJets.
split(
".")) == 2
and not self.addToAllSelections:
142 fatJetsSelectionName = self.fatJets.
split(
".")[1]
144 fatJetsSelectionName = selectionName
145 if self.electronsSelectionName
is not None:
146 electronsSelectionName = self.electronsSelectionName
148 if len(self.electrons.
split(
".")) == 2
and not self.addToAllSelections:
149 electronsSelectionName = self.electrons.
split(
".")[1]
151 electronsSelectionName = selectionName
152 if self.muonsSelectionName
is not None:
153 muonsSelectionName = self.muonsSelectionName
155 if len(self.muons.
split(
".")) == 2
and not self.addToAllSelections:
156 muonsSelectionName = self.muons.
split(
".")[1]
158 muonsSelectionName = selectionName
159 if self.photonsSelectionName
is not None:
160 photonsSelectionName = self.photonsSelectionName
162 if len(self.photons.
split(
".")) == 2
and not self.addToAllSelections:
163 photonsSelectionName = self.photons.
split(
".")[1]
165 photonsSelectionName = selectionName
166 if self.tausSelectionName
is not None:
167 tausSelectionName = self.tausSelectionName
169 if len(self.taus.
split(
".")) == 2
and not self.addToAllSelections:
170 tausSelectionName = self.taus.
split(
".")[1]
172 tausSelectionName = selectionName
185 if self.electrons !=
"" :
186 if self.nominalOnlyUnifiedSelection:
187 self.makeUnionPreselectionAlg(config, self.electrons)
188 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORElectronsSelectAlg' + postfix )
189 electrons, alg.preselection = config.readNameAndSelection (self.electrons)
190 alg.particles = electrons
191 alg.selectionDecoration = inputLabel +
',as_char'
193 config.addOutputVar (self.electrons.
split(
'.')[0],
194 outputLabel +
'_%SYS%',
195 select_or_decoration,
196 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
197 enabled=(selectionName !=
''))
198 if self.nominalOnlyUnifiedSelection:
199 alg.preselection =
'unifiedSelectForOR'
202 if self.photons !=
"" :
203 if self.nominalOnlyUnifiedSelection:
204 self.makeUnionPreselectionAlg(config, self.photons)
205 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORPhotonsSelectAlg' + postfix )
206 photons, alg.preselection = config.readNameAndSelection (self.photons)
207 alg.particles = photons
208 alg.selectionDecoration = inputLabel +
',as_char'
209 config.addOutputVar (self.photons.
split(
'.')[0],
210 outputLabel +
'_%SYS%',
211 select_or_decoration,
212 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
213 enabled=(selectionName !=
''))
214 if self.nominalOnlyUnifiedSelection:
215 alg.preselection =
'unifiedSelectForOR'
218 if self.muons !=
"" :
219 if self.nominalOnlyUnifiedSelection:
220 self.makeUnionPreselectionAlg(config, self.muons)
221 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORMuonsSelectAlg' + postfix )
222 muons, alg.preselection = config.readNameAndSelection (self.muons)
223 alg.particles = muons
224 alg.selectionDecoration = inputLabel +
',as_char'
225 config.addOutputVar (self.muons.
split(
'.')[0],
226 outputLabel +
'_%SYS%',
227 select_or_decoration,
228 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
229 enabled=(selectionName !=
''))
230 if self.nominalOnlyUnifiedSelection:
231 alg.preselection =
'unifiedSelectForOR'
235 if self.nominalOnlyUnifiedSelection:
236 self.makeUnionPreselectionAlg(config, self.taus)
237 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORTausSelectAlg' + postfix )
238 taus, alg.preselection = config.readNameAndSelection (self.taus)
240 alg.selectionDecoration = inputLabel +
',as_char'
241 config.addOutputVar (self.taus.
split(
'.')[0],
242 outputLabel +
'_%SYS%',
243 select_or_decoration,
244 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
245 enabled=(selectionName !=
''))
246 if self.nominalOnlyUnifiedSelection:
247 alg.preselection =
'unifiedSelectForOR'
251 if self.nominalOnlyUnifiedSelection:
252 self.makeUnionPreselectionAlg(config, self.jets)
253 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORJetsSelectAlg' + postfix )
254 jets, alg.preselection = config.readNameAndSelection (self.jets)
256 alg.selectionDecoration = inputLabel +
',as_char'
257 config.addOutputVar (self.jets.
split(
'.')[0],
258 outputLabel +
'_%SYS%',
259 select_or_decoration,
260 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
261 enabled=(selectionName !=
''))
262 if self.nominalOnlyUnifiedSelection:
263 alg.preselection =
'unifiedSelectForOR'
266 if self.fatJets !=
"" :
267 if self.nominalOnlyUnifiedSelection:
268 self.makeUnionPreselectionAlg(config, self.fatJets)
269 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORFatJetsSelectAlg' + postfix )
270 fatJets, alg.preselection = config.readNameAndSelection (self.fatJets)
271 alg.particles = fatJets
272 alg.selectionDecoration = inputLabel +
',as_char'
273 config.addOutputVar (self.fatJets.
split(
'.')[0],
274 outputLabel +
'_%SYS%',
275 select_or_decoration,
276 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
277 enabled=(selectionName !=
''))
278 if self.nominalOnlyUnifiedSelection:
279 alg.preselection =
'unifiedSelectForOR'
283 alg = config.createAlgorithm(
'CP::OverlapRemovalAlg',
'OverlapRemovalAlg' + postfix )
284 alg.OutputLabel = outputLabel
285 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
286 alg.affectingSystematicsFilter =
'.*'
288 alg.electrons = electrons
289 alg.electronsDecoration = outputLabel +
'_%SYS%,as_char'
290 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.electronsDecoration, preselection=
False, comesFrom=
'or')
293 alg.muonsDecoration = outputLabel +
'_%SYS%,as_char'
294 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.muonsDecoration, preselection=
False, comesFrom=
'or')
297 alg.tausDecoration = outputLabel +
'_%SYS%,as_char'
298 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.tausDecoration, preselection=
False, comesFrom=
'or')
301 alg.jetsDecoration = outputLabel +
'_%SYS%,as_char'
302 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.jetsDecoration, preselection=
False, comesFrom=
'or')
304 alg.photons = photons
305 alg.photonsDecoration = outputLabel +
'_%SYS%,as_char'
306 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.photonsDecoration, preselection=
False, comesFrom=
'or')
308 alg.fatJets = fatJets
309 alg.fatJetsDecoration = outputLabel +
'_%SYS%,as_char'
310 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.fatJetsDecoration, preselection=
False, comesFrom=
'or')
313 config.addPrivateTool(
'overlapTool',
'ORUtils::OverlapRemovalTool' )
314 alg.overlapTool.InputLabel = inputLabel
315 alg.overlapTool.OutputLabel = outputLabel
322 alg.overlapTool.OutputPassValue =
True
325 if electrons
and self.doEleEleOR:
326 config.addPrivateTool(
'overlapTool.EleEleORT',
327 'ORUtils::EleEleOverlapTool' )
328 alg.overlapTool.EleEleORT.InputLabel = inputLabel
329 alg.overlapTool.EleEleORT.OutputLabel = outputLabel
330 alg.overlapTool.EleEleORT.LinkOverlapObjects = self.linkOverlapObjects
331 alg.overlapTool.EleEleORT.OutputPassValue =
True
334 if electrons
and muons
and self.doEleMuOR:
335 config.addPrivateTool(
'overlapTool.EleMuORT',
336 'ORUtils::EleMuSharedTrkOverlapTool' )
337 alg.overlapTool.EleMuORT.InputLabel = inputLabel
338 alg.overlapTool.EleMuORT.OutputLabel = outputLabel
339 alg.overlapTool.EleMuORT.LinkOverlapObjects = self.linkOverlapObjects
340 alg.overlapTool.EleMuORT.OutputPassValue =
True
343 if electrons
and jets
and self.doEleJetOR:
344 config.addPrivateTool(
'overlapTool.EleJetORT',
345 'ORUtils::EleJetOverlapTool' )
346 alg.overlapTool.EleJetORT.InputLabel = inputLabel
347 alg.overlapTool.EleJetORT.OutputLabel = outputLabel
348 alg.overlapTool.EleJetORT.LinkOverlapObjects = self.linkOverlapObjects
349 alg.overlapTool.EleJetORT.BJetLabel = self.bJetLabel
350 alg.overlapTool.EleJetORT.UseSlidingDR = self.boostedLeptons
351 alg.overlapTool.EleJetORT.EnableUserPriority = self.enableUserPriority
352 alg.overlapTool.EleJetORT.OutputPassValue =
True
355 if muons
and jets
and self.doMuJetOR:
356 config.addPrivateTool(
'overlapTool.MuJetORT',
357 'ORUtils::MuJetOverlapTool' )
358 alg.overlapTool.MuJetORT.InputLabel = inputLabel
359 alg.overlapTool.MuJetORT.OutputLabel = outputLabel
360 alg.overlapTool.MuJetORT.LinkOverlapObjects = self.linkOverlapObjects
361 alg.overlapTool.MuJetORT.BJetLabel = self.bJetLabel
362 alg.overlapTool.MuJetORT.UseSlidingDR = self.boostedLeptons
363 alg.overlapTool.MuJetORT.EnableUserPriority = self.enableUserPriority
364 alg.overlapTool.MuJetORT.OutputPassValue =
True
367 if taus
and electrons
and self.doTauEleOR:
368 config.addPrivateTool(
'overlapTool.TauEleORT',
369 'ORUtils::DeltaROverlapTool' )
370 alg.overlapTool.TauEleORT.InputLabel = inputLabel
371 alg.overlapTool.TauEleORT.OutputLabel = outputLabel
372 alg.overlapTool.TauEleORT.LinkOverlapObjects = self.linkOverlapObjects
373 alg.overlapTool.TauEleORT.DR = 0.2
374 alg.overlapTool.TauEleORT.OutputPassValue =
True
377 if taus
and muons
and self.doTauMuOR:
378 config.addPrivateTool(
'overlapTool.TauMuORT',
379 'ORUtils::DeltaROverlapTool' )
380 alg.overlapTool.TauMuORT.InputLabel = inputLabel
381 alg.overlapTool.TauMuORT.OutputLabel = outputLabel
382 alg.overlapTool.TauMuORT.LinkOverlapObjects = self.linkOverlapObjects
383 alg.overlapTool.TauMuORT.DR = 0.2
384 alg.overlapTool.TauMuORT.OutputPassValue =
True
387 if taus
and jets
and self.doTauJetOR:
388 if self.doTauAntiTauJetOR:
389 config.addPrivateTool(
'overlapTool.TauJetORT',
390 'ORUtils::TauAntiTauJetOverlapTool' )
391 alg.overlapTool.TauJetORT.TauLabel = self.antiTauIDTauLabel
392 alg.overlapTool.TauJetORT.AntiTauLabel = self.antiTauLabel
393 alg.overlapTool.TauJetORT.BJetLabel = self.antiTauBJetLabel
395 config.addPrivateTool(
'overlapTool.TauJetORT',
396 'ORUtils::DeltaROverlapTool' )
398 alg.overlapTool.TauJetORT.InputLabel = inputLabel
399 alg.overlapTool.TauJetORT.OutputLabel = outputLabel
400 alg.overlapTool.TauJetORT.LinkOverlapObjects = self.linkOverlapObjects
401 alg.overlapTool.TauJetORT.DR = 0.2
402 alg.overlapTool.TauJetORT.EnableUserPriority = self.enableUserPriority
403 alg.overlapTool.TauJetORT.OutputPassValue =
True
406 if photons
and electrons
and self.doPhEleOR:
407 config.addPrivateTool(
'overlapTool.PhoEleORT',
408 'ORUtils::DeltaROverlapTool' )
409 alg.overlapTool.PhoEleORT.InputLabel = inputLabel
410 alg.overlapTool.PhoEleORT.OutputLabel = outputLabel
411 alg.overlapTool.PhoEleORT.LinkOverlapObjects = self.linkOverlapObjects
412 alg.overlapTool.PhoEleORT.OutputPassValue =
True
415 if photons
and muons
and self.doPhMuOR:
416 config.addPrivateTool(
'overlapTool.PhoMuORT',
417 'ORUtils::DeltaROverlapTool' )
418 alg.overlapTool.PhoMuORT.InputLabel = inputLabel
419 alg.overlapTool.PhoMuORT.OutputLabel = outputLabel
420 alg.overlapTool.PhoMuORT.LinkOverlapObjects = self.linkOverlapObjects
421 alg.overlapTool.PhoMuORT.OutputPassValue =
True
424 if photons
and jets
and self.doPhJetOR:
425 config.addPrivateTool(
'overlapTool.PhoJetORT',
426 'ORUtils::DeltaROverlapTool' )
427 alg.overlapTool.PhoJetORT.InputLabel = inputLabel
428 alg.overlapTool.PhoJetORT.OutputLabel = outputLabel
429 alg.overlapTool.PhoJetORT.LinkOverlapObjects = self.linkOverlapObjects
430 alg.overlapTool.PhoJetORT.EnableUserPriority = self.enableUserPriority
431 alg.overlapTool.PhoJetORT.OutputPassValue =
True
434 if electrons
and fatJets
and self.doEleFatJetOR:
435 config.addPrivateTool(
'overlapTool.EleFatJetORT',
436 'ORUtils::DeltaROverlapTool' )
437 alg.overlapTool.EleFatJetORT.InputLabel = inputLabel
438 alg.overlapTool.EleFatJetORT.OutputLabel = outputLabel
439 alg.overlapTool.EleFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
440 alg.overlapTool.EleFatJetORT.DR = 1.0
441 alg.overlapTool.EleFatJetORT.OutputPassValue =
True
444 if jets
and fatJets
and self.doJetFatJetOR:
445 config.addPrivateTool(
'overlapTool.JetFatJetORT',
446 'ORUtils::DeltaROverlapTool' )
447 alg.overlapTool.JetFatJetORT.InputLabel = inputLabel
448 alg.overlapTool.JetFatJetORT.OutputLabel = outputLabel
449 alg.overlapTool.JetFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
450 alg.overlapTool.JetFatJetORT.DR = 1.0
451 alg.overlapTool.JetFatJetORT.OutputPassValue =
True
453 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
455 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORElectronsCopyAlg' + postfix)
456 alg.particles = electrons
457 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
459 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORMuonsCopyAlg' + postfix)
460 alg.particles = muons
461 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
463 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORTausCopyAlg' + postfix)
465 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
467 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORJetsCopyAlg' + postfix)
469 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
471 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORPhotonsCopyAlg' + postfix)
472 alg.particles = photons
473 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
475 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORFatJetsCopyAlg' + postfix)
476 alg.particles = fatJets
477 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
480 if self.addPreselection:
481 if self.preselectLabel
is not None :
482 preselectLabel = self.preselectLabel
484 preselectLabel = outputLabel
487 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORElectronsPreselectionAlg' + postfix )
488 alg.particles = electrons
489 alg.preselection =
'&&'.join (config.getPreselection (self.electrons.
split(
'.')[0], electronsSelectionName, asList=
True)
490 + [outputLabel +
'_%SYS%,as_char'])
491 alg.selectionDecoration = preselectLabel
492 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
494 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORMuonsPreselectionAlg' + postfix )
495 alg.particles = muons
496 alg.preselection =
'&&'.join (config.getPreselection (self.muons.
split(
'.')[0], muonsSelectionName, asList=
True)
497 + [outputLabel +
'_%SYS%,as_char'])
498 alg.selectionDecoration = preselectLabel
499 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
501 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORTausPreselectionAlg' + postfix )
503 alg.preselection =
'&&'.join (config.getPreselection (self.taus.
split(
'.')[0], tausSelectionName, asList=
True)
504 + [outputLabel +
'_%SYS%,as_char'])
505 alg.selectionDecoration = preselectLabel
506 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
508 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORJetsPreselectionAlg' + postfix )
510 alg.preselection =
'&&'.join (config.getPreselection (self.jets.
split(
'.')[0], jetsSelectionName, asList=
True)
511 + [outputLabel +
'_%SYS%,as_char'])
512 alg.selectionDecoration = preselectLabel
513 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
515 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORPhotonsPreselectionAlg' + postfix )
516 alg.particles = photons
517 alg.preselection =
'&&'.join (config.getPreselection (self.photons.
split(
'.')[0], photonsSelectionName, asList=
True)
518 + [outputLabel +
'_%SYS%,as_char'])
519 alg.selectionDecoration = preselectLabel
520 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
522 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORFatJetsPreselectionAlg' + postfix )
523 alg.particles = fatJets
524 alg.preselection =
'&&'.join (config.getPreselection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, asList=
True)
525 + [outputLabel +
'_%SYS%,as_char'])
526 alg.selectionDecoration = preselectLabel
527 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')