144 log = logging.getLogger(
'OverlapRemovalConfig')
154 numORblocks = OverlapAnalysisConfig.get_instance_count()
166 if self.selectionName
is not None:
167 selectionName = self.selectionName
168 outputLabel = self.outputLabel +
'_' + selectionName
169 inputLabel = self.inputLabel +
'_' + selectionName
170 select_or_decoration =
'select_or_' + self.selectionName
174 select_or_decoration =
'select_or'
176 selectionName = self.outputLabel
177 select_or_decoration =
'select_' + self.outputLabel
178 outputLabel = self.outputLabel
179 inputLabel = self.inputLabel
182 if OverlapAnalysisConfig.get_instance_count() > 1:
185 log.warning(
"More than one OverlapRemoval config scheduled but 'addToAllSelections' is set to True. This is probably not what you want.")
188 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for electrons with 'electronsSelectionName'.")
192 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for muons with 'muonsSelectionName'.")
196 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for photons with 'photonsSelectionName'.")
200 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for tau-jets with 'tausSelectionName'.")
204 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for jets with 'jetsSelectionName'.")
208 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for large-R jets with 'fatJetsSelectionName'.")
217 jetsSelectionName = selectionName
221 fatJetsSelectionName = selectionName
225 electronsSelectionName = selectionName
229 muonsSelectionName = selectionName
233 photonsSelectionName = selectionName
237 tausSelectionName = selectionName
250 def enableOutput(containerName, selectionName):
256 if selectionName ==
'':
260 if selectionName
in config.getSelectionNames(containerName.split(
".")[0]):
274 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORElectronsSelectAlg' )
275 electrons, alg.preselection = config.readNameAndSelection (self.
electrons)
276 alg.particles = electrons
277 alg.selectionDecoration = inputLabel +
',as_char'
278 if enableOutput(self.
electrons, electronsSelectionName):
281 outputLabel +
'_%SYS%',
285 alg.preselection =
'unifiedSelectForOR'
291 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORPhotonsSelectAlg' )
292 photons, alg.preselection = config.readNameAndSelection (self.
photons)
293 alg.particles = photons
294 alg.selectionDecoration = inputLabel +
',as_char'
295 if enableOutput(self.
photons, photonsSelectionName):
298 outputLabel +
'_%SYS%',
302 alg.preselection =
'unifiedSelectForOR'
305 if self.
muons !=
"" :
308 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORMuonsSelectAlg' )
309 muons, alg.preselection = config.readNameAndSelection (self.
muons)
310 alg.particles = muons
311 alg.selectionDecoration = inputLabel +
',as_char'
312 if enableOutput(self.
muons, muonsSelectionName):
314 config.addOutputVar (self.
muons.
split(
'.')[0],
315 outputLabel +
'_%SYS%',
319 alg.preselection =
'unifiedSelectForOR'
325 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORTausSelectAlg' )
326 taus, alg.preselection = config.readNameAndSelection (self.
taus)
328 alg.selectionDecoration = inputLabel +
',as_char'
329 if enableOutput(self.
taus, tausSelectionName):
331 config.addOutputVar (self.
taus.
split(
'.')[0],
332 outputLabel +
'_%SYS%',
336 alg.preselection =
'unifiedSelectForOR'
342 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORJetsSelectAlg' )
343 jets, alg.preselection = config.readNameAndSelection (self.
jets)
345 alg.selectionDecoration = inputLabel +
',as_char'
346 if enableOutput(self.
jets, jetsSelectionName):
348 config.addOutputVar (self.
jets.
split(
'.')[0],
349 outputLabel +
'_%SYS%',
353 alg.preselection =
'unifiedSelectForOR'
359 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORFatJetsSelectAlg' )
360 fatJets, alg.preselection = config.readNameAndSelection (self.
fatJets)
361 alg.particles = fatJets
362 alg.selectionDecoration = inputLabel +
',as_char'
363 if enableOutput(self.
fatJets, fatJetsSelectionName):
366 outputLabel +
'_%SYS%',
370 alg.preselection =
'unifiedSelectForOR'
376 alg = config.createAlgorithm(
'CP::OverlapRemovalAlg',
'OverlapRemovalAlg' )
377 alg.OutputLabel = outputLabel
379 alg.affectingSystematicsFilter =
'.*'
381 alg.electrons = electrons
382 alg.electronsDecoration = outputLabel +
'_%SYS%,as_char'
383 config.addSelection (self.
electrons.
split(
'.')[0], electronsSelectionName, alg.electronsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
386 alg.muonsDecoration = outputLabel +
'_%SYS%,as_char'
387 config.addSelection (self.
muons.
split(
'.')[0], muonsSelectionName, alg.muonsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
390 alg.tausDecoration = outputLabel +
'_%SYS%,as_char'
391 config.addSelection (self.
taus.
split(
'.')[0], tausSelectionName, alg.tausDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
394 alg.jetsDecoration = outputLabel +
'_%SYS%,as_char'
395 config.addSelection (self.
jets.
split(
'.')[0], jetsSelectionName, alg.jetsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
397 alg.photons = photons
398 alg.photonsDecoration = outputLabel +
'_%SYS%,as_char'
399 config.addSelection (self.
photons.
split(
'.')[0], photonsSelectionName, alg.photonsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
401 alg.fatJets = fatJets
402 alg.fatJetsDecoration = outputLabel +
'_%SYS%,as_char'
403 config.addSelection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, alg.fatJetsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
406 config.addPrivateTool(
'overlapTool',
'ORUtils::OverlapRemovalTool' )
407 alg.overlapTool.InputLabel = inputLabel
408 alg.overlapTool.OutputLabel = outputLabel
415 alg.overlapTool.OutputPassValue =
True
419 config.addPrivateTool(
'overlapTool.EleEleORT',
420 'ORUtils::EleEleOverlapTool' )
421 alg.overlapTool.EleEleORT.InputLabel = inputLabel
422 alg.overlapTool.EleEleORT.OutputLabel = outputLabel
423 alg.overlapTool.EleEleORT.LinkOverlapObjects = self.linkOverlapObjects
424 alg.overlapTool.EleEleORT.OutputPassValue =
True
428 config.addPrivateTool(
'overlapTool.EleMuORT',
429 'ORUtils::EleMuSharedTrkOverlapTool' )
430 alg.overlapTool.EleMuORT.InputLabel = inputLabel
431 alg.overlapTool.EleMuORT.OutputLabel = outputLabel
432 alg.overlapTool.EleMuORT.LinkOverlapObjects = self.linkOverlapObjects
433 alg.overlapTool.EleMuORT.OutputPassValue =
True
437 config.addPrivateTool(
'overlapTool.EleJetORT',
438 'ORUtils::EleJetOverlapTool' )
439 alg.overlapTool.EleJetORT.InputLabel = inputLabel
440 alg.overlapTool.EleJetORT.OutputLabel = outputLabel
441 alg.overlapTool.EleJetORT.LinkOverlapObjects = self.linkOverlapObjects
442 alg.overlapTool.EleJetORT.BJetLabel = self.bJetLabel
443 alg.overlapTool.EleJetORT.InnerDR = self.InnerDR
444 alg.overlapTool.EleJetORT.OuterDR = self.OuterDR
445 alg.overlapTool.EleJetORT.UseSlidingDR = self.boostedLeptons
446 alg.overlapTool.EleJetORT.EnableUserPriority = self.enableUserPriority
447 alg.overlapTool.EleJetORT.OutputPassValue =
True
451 config.addPrivateTool(
'overlapTool.MuJetORT',
452 'ORUtils::MuJetOverlapTool' )
453 alg.overlapTool.MuJetORT.InputLabel = inputLabel
454 alg.overlapTool.MuJetORT.OutputLabel = outputLabel
455 alg.overlapTool.MuJetORT.LinkOverlapObjects = self.linkOverlapObjects
456 alg.overlapTool.MuJetORT.BJetLabel = self.bJetLabel
457 alg.overlapTool.MuJetORT.InnerDR = self.InnerDR
458 alg.overlapTool.MuJetORT.OuterDR = self.OuterDR
459 alg.overlapTool.MuJetORT.UseSlidingDR = self.boostedLeptons
460 alg.overlapTool.MuJetORT.EnableUserPriority = self.enableUserPriority
461 alg.overlapTool.MuJetORT.OutputPassValue =
True
462 alg.overlapTool.MuJetORT.AllowNoPV = self.allowNoPV
466 config.addPrivateTool(
'overlapTool.TauEleORT',
467 'ORUtils::DeltaROverlapTool' )
468 alg.overlapTool.TauEleORT.InputLabel = inputLabel
469 alg.overlapTool.TauEleORT.OutputLabel = outputLabel
470 alg.overlapTool.TauEleORT.LinkOverlapObjects = self.linkOverlapObjects
471 alg.overlapTool.TauEleORT.DR = 0.2
472 alg.overlapTool.TauEleORT.OutputPassValue =
True
476 config.addPrivateTool(
'overlapTool.TauMuORT',
477 'ORUtils::DeltaROverlapTool' )
478 alg.overlapTool.TauMuORT.InputLabel = inputLabel
479 alg.overlapTool.TauMuORT.OutputLabel = outputLabel
480 alg.overlapTool.TauMuORT.LinkOverlapObjects = self.linkOverlapObjects
481 alg.overlapTool.TauMuORT.DR = 0.2
482 alg.overlapTool.TauMuORT.OutputPassValue =
True
487 config.addPrivateTool(
'overlapTool.TauJetORT',
488 'ORUtils::TauAntiTauJetOverlapTool' )
489 alg.overlapTool.TauJetORT.TauLabel = self.antiTauIDTauLabel
490 alg.overlapTool.TauJetORT.AntiTauLabel = self.antiTauLabel
491 alg.overlapTool.TauJetORT.BJetLabel = self.antiTauBJetLabel
493 config.addPrivateTool(
'overlapTool.TauJetORT',
494 'ORUtils::DeltaROverlapTool' )
496 alg.overlapTool.TauJetORT.InputLabel = inputLabel
497 alg.overlapTool.TauJetORT.OutputLabel = outputLabel
498 alg.overlapTool.TauJetORT.LinkOverlapObjects = self.linkOverlapObjects
499 alg.overlapTool.TauJetORT.DR = 0.2
500 alg.overlapTool.TauJetORT.EnableUserPriority = self.enableUserPriority
501 alg.overlapTool.TauJetORT.OutputPassValue =
True
505 config.addPrivateTool(
'overlapTool.PhoEleORT',
506 'ORUtils::DeltaROverlapTool' )
507 alg.overlapTool.PhoEleORT.InputLabel = inputLabel
508 alg.overlapTool.PhoEleORT.OutputLabel = outputLabel
509 alg.overlapTool.PhoEleORT.LinkOverlapObjects = self.linkOverlapObjects
510 alg.overlapTool.PhoEleORT.OutputPassValue =
True
512 alg.overlapTool.PhoEleORT.SwapContainerPrecedence =
True
516 config.addPrivateTool(
'overlapTool.PhoMuORT',
517 'ORUtils::DeltaROverlapTool' )
518 alg.overlapTool.PhoMuORT.InputLabel = inputLabel
519 alg.overlapTool.PhoMuORT.OutputLabel = outputLabel
520 alg.overlapTool.PhoMuORT.LinkOverlapObjects = self.linkOverlapObjects
521 alg.overlapTool.PhoMuORT.OutputPassValue =
True
523 alg.overlapTool.PhoMuORT.SwapContainerPrecedence =
True
527 config.addPrivateTool(
'overlapTool.PhoJetORT',
528 'ORUtils::DeltaROverlapTool' )
529 alg.overlapTool.PhoJetORT.InputLabel = inputLabel
530 alg.overlapTool.PhoJetORT.OutputLabel = outputLabel
531 alg.overlapTool.PhoJetORT.LinkOverlapObjects = self.linkOverlapObjects
532 alg.overlapTool.PhoJetORT.EnableUserPriority = self.enableUserPriority
533 alg.overlapTool.PhoJetORT.OutputPassValue =
True
537 config.addPrivateTool(
'overlapTool.EleFatJetORT',
538 'ORUtils::DeltaROverlapTool' )
539 alg.overlapTool.EleFatJetORT.InputLabel = inputLabel
540 alg.overlapTool.EleFatJetORT.OutputLabel = outputLabel
541 alg.overlapTool.EleFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
542 alg.overlapTool.EleFatJetORT.DR = 1.0
543 alg.overlapTool.EleFatJetORT.OutputPassValue =
True
547 config.addPrivateTool(
'overlapTool.JetFatJetORT',
548 'ORUtils::DeltaROverlapTool' )
549 alg.overlapTool.JetFatJetORT.InputLabel = inputLabel
550 alg.overlapTool.JetFatJetORT.OutputLabel = outputLabel
551 alg.overlapTool.JetFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
552 alg.overlapTool.JetFatJetORT.DR = 1.0
553 alg.overlapTool.JetFatJetORT.OutputPassValue =
True
557 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORElectronsCopyAlg')
558 alg.particles = electrons
559 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
561 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORMuonsCopyAlg')
562 alg.particles = muons
563 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
565 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORTausCopyAlg')
567 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
569 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORJetsCopyAlg')
571 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
573 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORPhotonsCopyAlg')
574 alg.particles = photons
575 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
577 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORFatJetsCopyAlg')
578 alg.particles = fatJets
579 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
583 if self.preselectLabel
is not None :
584 preselectLabel = self.preselectLabel
586 preselectLabel = outputLabel
589 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORElectronsPreselectionAlg')
590 alg.particles = electrons
591 alg.preselection =
'&&'.join (config.getPreselection (self.
electrons.
split(
'.')[0], electronsSelectionName, asList=
True)
592 + [outputLabel +
'_%SYS%,as_char'])
593 alg.selectionDecoration = preselectLabel
594 config.addSelection (self.
electrons.
split(
'.')[0], electronsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
596 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORMuonsPreselectionAlg')
597 alg.particles = muons
598 alg.preselection =
'&&'.join (config.getPreselection (self.
muons.
split(
'.')[0], muonsSelectionName, asList=
True)
599 + [outputLabel +
'_%SYS%,as_char'])
600 alg.selectionDecoration = preselectLabel
601 config.addSelection (self.
muons.
split(
'.')[0], muonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
603 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORTausPreselectionAlg')
605 alg.preselection =
'&&'.join (config.getPreselection (self.
taus.
split(
'.')[0], tausSelectionName, asList=
True)
606 + [outputLabel +
'_%SYS%,as_char'])
607 alg.selectionDecoration = preselectLabel
608 config.addSelection (self.
taus.
split(
'.')[0], tausSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
610 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORJetsPreselectionAlg')
612 alg.preselection =
'&&'.join (config.getPreselection (self.
jets.
split(
'.')[0], jetsSelectionName, asList=
True)
613 + [outputLabel +
'_%SYS%,as_char'])
614 alg.selectionDecoration = preselectLabel
615 config.addSelection (self.
jets.
split(
'.')[0], jetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
617 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORPhotonsPreselectionAlg')
618 alg.particles = photons
619 alg.preselection =
'&&'.join (config.getPreselection (self.
photons.
split(
'.')[0], photonsSelectionName, asList=
True)
620 + [outputLabel +
'_%SYS%,as_char'])
621 alg.selectionDecoration = preselectLabel
622 config.addSelection (self.
photons.
split(
'.')[0], photonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
624 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORFatJetsPreselectionAlg')
625 alg.particles = fatJets
626 alg.preselection =
'&&'.join (config.getPreselection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, asList=
True)
627 + [outputLabel +
'_%SYS%,as_char'])
628 alg.selectionDecoration = preselectLabel
629 config.addSelection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)