119 def makeAlgs (self, config) :
121 if self.addToAllSelections
is None:
129 numORblocks = OverlapAnalysisConfig.get_instance_count()
132 self.addToAllSelections =
True
133 if self.addPreselection
is None:
134 self.addPreselection =
False
137 self.addToAllSelections =
False
138 if self.addPreselection
is None:
139 self.addPreselection =
True
141 if self.selectionName
is not None:
142 selectionName = self.selectionName
143 outputLabel = self.outputLabel +
'_' + selectionName
144 inputLabel = self.inputLabel +
'_' + selectionName
145 select_or_decoration =
'select_or_' + self.selectionName
147 if self.addToAllSelections:
149 select_or_decoration =
'select_or'
151 selectionName = self.outputLabel
152 select_or_decoration =
'select_' + self.outputLabel
153 outputLabel = self.outputLabel
154 inputLabel = self.inputLabel
161 if self.jetsSelectionName
is not None:
162 jetsSelectionName = self.jetsSelectionName
164 if len(self.jets.
split(
".")) == 2
and not self.addToAllSelections:
165 jetsSelectionName = self.jets.
split(
".")[1]
167 jetsSelectionName = selectionName
168 if self.fatJetsSelectionName
is not None:
169 fatJetsSelectionName = self.fatJetsSelectionName
171 if len(self.fatJets.
split(
".")) == 2
and not self.addToAllSelections:
172 fatJetsSelectionName = self.fatJets.
split(
".")[1]
174 fatJetsSelectionName = selectionName
175 if self.electronsSelectionName
is not None:
176 electronsSelectionName = self.electronsSelectionName
178 if len(self.electrons.
split(
".")) == 2
and not self.addToAllSelections:
179 electronsSelectionName = self.electrons.
split(
".")[1]
181 electronsSelectionName = selectionName
182 if self.muonsSelectionName
is not None:
183 muonsSelectionName = self.muonsSelectionName
185 if len(self.muons.
split(
".")) == 2
and not self.addToAllSelections:
186 muonsSelectionName = self.muons.
split(
".")[1]
188 muonsSelectionName = selectionName
189 if self.photonsSelectionName
is not None:
190 photonsSelectionName = self.photonsSelectionName
192 if len(self.photons.
split(
".")) == 2
and not self.addToAllSelections:
193 photonsSelectionName = self.photons.
split(
".")[1]
195 photonsSelectionName = selectionName
196 if self.tausSelectionName
is not None:
197 tausSelectionName = self.tausSelectionName
199 if len(self.taus.
split(
".")) == 2
and not self.addToAllSelections:
200 tausSelectionName = self.taus.
split(
".")[1]
202 tausSelectionName = selectionName
215 if self.electrons !=
"" :
216 if self.nominalOnlyUnifiedSelection:
217 self.makeUnionPreselectionAlg(config, self.electrons)
218 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORElectronsSelectAlg' )
219 electrons, alg.preselection = config.readNameAndSelection (self.electrons)
220 alg.particles = electrons
221 alg.selectionDecoration = inputLabel +
',as_char'
223 config.addOutputVar (self.electrons.
split(
'.')[0],
224 outputLabel +
'_%SYS%',
225 select_or_decoration,
226 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
227 enabled=(selectionName !=
'' and not self.addPreselection))
228 if self.nominalOnlyUnifiedSelection:
229 alg.preselection =
'unifiedSelectForOR'
232 if self.photons !=
"" :
233 if self.nominalOnlyUnifiedSelection:
234 self.makeUnionPreselectionAlg(config, self.photons)
235 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORPhotonsSelectAlg' )
236 photons, alg.preselection = config.readNameAndSelection (self.photons)
237 alg.particles = photons
238 alg.selectionDecoration = inputLabel +
',as_char'
239 config.addOutputVar (self.photons.
split(
'.')[0],
240 outputLabel +
'_%SYS%',
241 select_or_decoration,
242 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
243 enabled=(selectionName !=
'' and not self.addPreselection))
244 if self.nominalOnlyUnifiedSelection:
245 alg.preselection =
'unifiedSelectForOR'
248 if self.muons !=
"" :
249 if self.nominalOnlyUnifiedSelection:
250 self.makeUnionPreselectionAlg(config, self.muons)
251 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORMuonsSelectAlg' )
252 muons, alg.preselection = config.readNameAndSelection (self.muons)
253 alg.particles = muons
254 alg.selectionDecoration = inputLabel +
',as_char'
255 config.addOutputVar (self.muons.
split(
'.')[0],
256 outputLabel +
'_%SYS%',
257 select_or_decoration,
258 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
259 enabled=(selectionName !=
'' and not self.addPreselection))
260 if self.nominalOnlyUnifiedSelection:
261 alg.preselection =
'unifiedSelectForOR'
265 if self.nominalOnlyUnifiedSelection:
266 self.makeUnionPreselectionAlg(config, self.taus)
267 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORTausSelectAlg' )
268 taus, alg.preselection = config.readNameAndSelection (self.taus)
270 alg.selectionDecoration = inputLabel +
',as_char'
271 config.addOutputVar (self.taus.
split(
'.')[0],
272 outputLabel +
'_%SYS%',
273 select_or_decoration,
274 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
275 enabled=(selectionName !=
'' and not self.addPreselection))
276 if self.nominalOnlyUnifiedSelection:
277 alg.preselection =
'unifiedSelectForOR'
281 if self.nominalOnlyUnifiedSelection:
282 self.makeUnionPreselectionAlg(config, self.jets)
283 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORJetsSelectAlg' )
284 jets, alg.preselection = config.readNameAndSelection (self.jets)
286 alg.selectionDecoration = inputLabel +
',as_char'
287 config.addOutputVar (self.jets.
split(
'.')[0],
288 outputLabel +
'_%SYS%',
289 select_or_decoration,
290 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
291 enabled=(selectionName !=
'' and not self.addPreselection))
292 if self.nominalOnlyUnifiedSelection:
293 alg.preselection =
'unifiedSelectForOR'
296 if self.fatJets !=
"" :
297 if self.nominalOnlyUnifiedSelection:
298 self.makeUnionPreselectionAlg(config, self.fatJets)
299 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORFatJetsSelectAlg' )
300 fatJets, alg.preselection = config.readNameAndSelection (self.fatJets)
301 alg.particles = fatJets
302 alg.selectionDecoration = inputLabel +
',as_char'
303 config.addOutputVar (self.fatJets.
split(
'.')[0],
304 outputLabel +
'_%SYS%',
305 select_or_decoration,
306 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
307 enabled=(selectionName !=
'' and not self.addPreselection))
308 if self.nominalOnlyUnifiedSelection:
309 alg.preselection =
'unifiedSelectForOR'
313 alg = config.createAlgorithm(
'CP::OverlapRemovalAlg',
'OverlapRemovalAlg' )
314 alg.OutputLabel = outputLabel
315 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
316 alg.affectingSystematicsFilter =
'.*'
318 alg.electrons = electrons
319 alg.electronsDecoration = outputLabel +
'_%SYS%,as_char'
320 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.electronsDecoration, preselection=
False, comesFrom=
'or')
323 alg.muonsDecoration = outputLabel +
'_%SYS%,as_char'
324 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.muonsDecoration, preselection=
False, comesFrom=
'or')
327 alg.tausDecoration = outputLabel +
'_%SYS%,as_char'
328 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.tausDecoration, preselection=
False, comesFrom=
'or')
331 alg.jetsDecoration = outputLabel +
'_%SYS%,as_char'
332 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.jetsDecoration, preselection=
False, comesFrom=
'or')
334 alg.photons = photons
335 alg.photonsDecoration = outputLabel +
'_%SYS%,as_char'
336 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.photonsDecoration, preselection=
False, comesFrom=
'or')
338 alg.fatJets = fatJets
339 alg.fatJetsDecoration = outputLabel +
'_%SYS%,as_char'
340 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.fatJetsDecoration, preselection=
False, comesFrom=
'or')
343 config.addPrivateTool(
'overlapTool',
'ORUtils::OverlapRemovalTool' )
344 alg.overlapTool.InputLabel = inputLabel
345 alg.overlapTool.OutputLabel = outputLabel
352 alg.overlapTool.OutputPassValue =
True
355 if electrons
and self.doEleEleOR:
356 config.addPrivateTool(
'overlapTool.EleEleORT',
357 'ORUtils::EleEleOverlapTool' )
358 alg.overlapTool.EleEleORT.InputLabel = inputLabel
359 alg.overlapTool.EleEleORT.OutputLabel = outputLabel
360 alg.overlapTool.EleEleORT.LinkOverlapObjects = self.linkOverlapObjects
361 alg.overlapTool.EleEleORT.OutputPassValue =
True
364 if electrons
and muons
and self.doEleMuOR:
365 config.addPrivateTool(
'overlapTool.EleMuORT',
366 'ORUtils::EleMuSharedTrkOverlapTool' )
367 alg.overlapTool.EleMuORT.InputLabel = inputLabel
368 alg.overlapTool.EleMuORT.OutputLabel = outputLabel
369 alg.overlapTool.EleMuORT.LinkOverlapObjects = self.linkOverlapObjects
370 alg.overlapTool.EleMuORT.OutputPassValue =
True
373 if electrons
and jets
and self.doEleJetOR:
374 config.addPrivateTool(
'overlapTool.EleJetORT',
375 'ORUtils::EleJetOverlapTool' )
376 alg.overlapTool.EleJetORT.InputLabel = inputLabel
377 alg.overlapTool.EleJetORT.OutputLabel = outputLabel
378 alg.overlapTool.EleJetORT.LinkOverlapObjects = self.linkOverlapObjects
379 alg.overlapTool.EleJetORT.BJetLabel = self.bJetLabel
380 alg.overlapTool.EleJetORT.InnerDR = self.InnerDR
381 alg.overlapTool.EleJetORT.OuterDR = self.OuterDR
382 alg.overlapTool.EleJetORT.UseSlidingDR = self.boostedLeptons
383 alg.overlapTool.EleJetORT.EnableUserPriority = self.enableUserPriority
384 alg.overlapTool.EleJetORT.OutputPassValue =
True
387 if muons
and jets
and self.doMuJetOR:
388 config.addPrivateTool(
'overlapTool.MuJetORT',
389 'ORUtils::MuJetOverlapTool' )
390 alg.overlapTool.MuJetORT.InputLabel = inputLabel
391 alg.overlapTool.MuJetORT.OutputLabel = outputLabel
392 alg.overlapTool.MuJetORT.LinkOverlapObjects = self.linkOverlapObjects
393 alg.overlapTool.MuJetORT.BJetLabel = self.bJetLabel
394 alg.overlapTool.MuJetORT.InnerDR = self.InnerDR
395 alg.overlapTool.MuJetORT.OuterDR = self.OuterDR
396 alg.overlapTool.MuJetORT.UseSlidingDR = self.boostedLeptons
397 alg.overlapTool.MuJetORT.EnableUserPriority = self.enableUserPriority
398 alg.overlapTool.MuJetORT.OutputPassValue =
True
401 if taus
and electrons
and self.doTauEleOR:
402 config.addPrivateTool(
'overlapTool.TauEleORT',
403 'ORUtils::DeltaROverlapTool' )
404 alg.overlapTool.TauEleORT.InputLabel = inputLabel
405 alg.overlapTool.TauEleORT.OutputLabel = outputLabel
406 alg.overlapTool.TauEleORT.LinkOverlapObjects = self.linkOverlapObjects
407 alg.overlapTool.TauEleORT.DR = 0.2
408 alg.overlapTool.TauEleORT.OutputPassValue =
True
411 if taus
and muons
and self.doTauMuOR:
412 config.addPrivateTool(
'overlapTool.TauMuORT',
413 'ORUtils::DeltaROverlapTool' )
414 alg.overlapTool.TauMuORT.InputLabel = inputLabel
415 alg.overlapTool.TauMuORT.OutputLabel = outputLabel
416 alg.overlapTool.TauMuORT.LinkOverlapObjects = self.linkOverlapObjects
417 alg.overlapTool.TauMuORT.DR = 0.2
418 alg.overlapTool.TauMuORT.OutputPassValue =
True
421 if taus
and jets
and self.doTauJetOR:
422 if self.doTauAntiTauJetOR:
423 config.addPrivateTool(
'overlapTool.TauJetORT',
424 'ORUtils::TauAntiTauJetOverlapTool' )
425 alg.overlapTool.TauJetORT.TauLabel = self.antiTauIDTauLabel
426 alg.overlapTool.TauJetORT.AntiTauLabel = self.antiTauLabel
427 alg.overlapTool.TauJetORT.BJetLabel = self.antiTauBJetLabel
429 config.addPrivateTool(
'overlapTool.TauJetORT',
430 'ORUtils::DeltaROverlapTool' )
432 alg.overlapTool.TauJetORT.InputLabel = inputLabel
433 alg.overlapTool.TauJetORT.OutputLabel = outputLabel
434 alg.overlapTool.TauJetORT.LinkOverlapObjects = self.linkOverlapObjects
435 alg.overlapTool.TauJetORT.DR = 0.2
436 alg.overlapTool.TauJetORT.EnableUserPriority = self.enableUserPriority
437 alg.overlapTool.TauJetORT.OutputPassValue =
True
440 if photons
and electrons
and self.doPhEleOR:
441 config.addPrivateTool(
'overlapTool.PhoEleORT',
442 'ORUtils::DeltaROverlapTool' )
443 alg.overlapTool.PhoEleORT.InputLabel = inputLabel
444 alg.overlapTool.PhoEleORT.OutputLabel = outputLabel
445 alg.overlapTool.PhoEleORT.LinkOverlapObjects = self.linkOverlapObjects
446 alg.overlapTool.PhoEleORT.OutputPassValue =
True
447 if self.favourPhotonOverLepton:
448 alg.overlapTool.PhoEleORT.SwapContainerPrecedence =
True
451 if photons
and muons
and self.doPhMuOR:
452 config.addPrivateTool(
'overlapTool.PhoMuORT',
453 'ORUtils::DeltaROverlapTool' )
454 alg.overlapTool.PhoMuORT.InputLabel = inputLabel
455 alg.overlapTool.PhoMuORT.OutputLabel = outputLabel
456 alg.overlapTool.PhoMuORT.LinkOverlapObjects = self.linkOverlapObjects
457 alg.overlapTool.PhoMuORT.OutputPassValue =
True
458 if self.favourPhotonOverLepton:
459 alg.overlapTool.PhoMuORT.SwapContainerPrecedence =
True
462 if photons
and jets
and self.doPhJetOR:
463 config.addPrivateTool(
'overlapTool.PhoJetORT',
464 'ORUtils::DeltaROverlapTool' )
465 alg.overlapTool.PhoJetORT.InputLabel = inputLabel
466 alg.overlapTool.PhoJetORT.OutputLabel = outputLabel
467 alg.overlapTool.PhoJetORT.LinkOverlapObjects = self.linkOverlapObjects
468 alg.overlapTool.PhoJetORT.EnableUserPriority = self.enableUserPriority
469 alg.overlapTool.PhoJetORT.OutputPassValue =
True
472 if electrons
and fatJets
and self.doEleFatJetOR:
473 config.addPrivateTool(
'overlapTool.EleFatJetORT',
474 'ORUtils::DeltaROverlapTool' )
475 alg.overlapTool.EleFatJetORT.InputLabel = inputLabel
476 alg.overlapTool.EleFatJetORT.OutputLabel = outputLabel
477 alg.overlapTool.EleFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
478 alg.overlapTool.EleFatJetORT.DR = 1.0
479 alg.overlapTool.EleFatJetORT.OutputPassValue =
True
482 if jets
and fatJets
and self.doJetFatJetOR:
483 config.addPrivateTool(
'overlapTool.JetFatJetORT',
484 'ORUtils::DeltaROverlapTool' )
485 alg.overlapTool.JetFatJetORT.InputLabel = inputLabel
486 alg.overlapTool.JetFatJetORT.OutputLabel = outputLabel
487 alg.overlapTool.JetFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
488 alg.overlapTool.JetFatJetORT.DR = 1.0
489 alg.overlapTool.JetFatJetORT.OutputPassValue =
True
491 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
493 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORElectronsCopyAlg')
494 alg.particles = electrons
495 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
497 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORMuonsCopyAlg')
498 alg.particles = muons
499 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
501 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORTausCopyAlg')
503 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
505 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORJetsCopyAlg')
507 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
509 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORPhotonsCopyAlg')
510 alg.particles = photons
511 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
513 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORFatJetsCopyAlg')
514 alg.particles = fatJets
515 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
518 if self.addPreselection:
519 if self.preselectLabel
is not None :
520 preselectLabel = self.preselectLabel
522 preselectLabel = outputLabel
525 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORElectronsPreselectionAlg')
526 alg.particles = electrons
527 alg.preselection =
'&&'.join (config.getPreselection (self.electrons.
split(
'.')[0], electronsSelectionName, asList=
True)
528 + [outputLabel +
'_%SYS%,as_char'])
529 alg.selectionDecoration = preselectLabel
530 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
532 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORMuonsPreselectionAlg')
533 alg.particles = muons
534 alg.preselection =
'&&'.join (config.getPreselection (self.muons.
split(
'.')[0], muonsSelectionName, asList=
True)
535 + [outputLabel +
'_%SYS%,as_char'])
536 alg.selectionDecoration = preselectLabel
537 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
539 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORTausPreselectionAlg')
541 alg.preselection =
'&&'.join (config.getPreselection (self.taus.
split(
'.')[0], tausSelectionName, asList=
True)
542 + [outputLabel +
'_%SYS%,as_char'])
543 alg.selectionDecoration = preselectLabel
544 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
546 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORJetsPreselectionAlg')
548 alg.preselection =
'&&'.join (config.getPreselection (self.jets.
split(
'.')[0], jetsSelectionName, asList=
True)
549 + [outputLabel +
'_%SYS%,as_char'])
550 alg.selectionDecoration = preselectLabel
551 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
553 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORPhotonsPreselectionAlg')
554 alg.particles = photons
555 alg.preselection =
'&&'.join (config.getPreselection (self.photons.
split(
'.')[0], photonsSelectionName, asList=
True)
556 + [outputLabel +
'_%SYS%,as_char'])
557 alg.selectionDecoration = preselectLabel
558 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
560 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORFatJetsPreselectionAlg')
561 alg.particles = fatJets
562 alg.preselection =
'&&'.join (config.getPreselection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, asList=
True)
563 + [outputLabel +
'_%SYS%,as_char'])
564 alg.selectionDecoration = preselectLabel
565 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')