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 raise ValueError(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for electrons with 'electronsSelectionName'.")
191 raise ValueError(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for muons with 'muonsSelectionName'.")
194 raise ValueError(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for photons with 'photonsSelectionName'.")
197 raise ValueError(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for tau-jets with 'tausSelectionName'.")
200 raise ValueError(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for jets with 'jetsSelectionName'.")
203 raise ValueError(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for large-R jets with 'fatJetsSelectionName'.")
211 jetsSelectionName = selectionName
215 fatJetsSelectionName = selectionName
219 electronsSelectionName = selectionName
223 muonsSelectionName = selectionName
227 photonsSelectionName = selectionName
231 tausSelectionName = selectionName
244 def enableOutput(containerName, selectionName):
250 if selectionName ==
'':
254 if selectionName
in config.getSelectionNames(containerName.split(
".")[0]):
268 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORElectronsSelectAlg' )
269 electrons, alg.preselection = config.readNameAndSelection (self.
electrons)
270 alg.particles = electrons
271 alg.selectionDecoration = inputLabel +
',as_char'
272 if enableOutput(self.
electrons, electronsSelectionName):
275 outputLabel +
'_%SYS%',
279 alg.preselection =
'unifiedSelectForOR'
285 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORPhotonsSelectAlg' )
286 photons, alg.preselection = config.readNameAndSelection (self.
photons)
287 alg.particles = photons
288 alg.selectionDecoration = inputLabel +
',as_char'
289 if enableOutput(self.
photons, photonsSelectionName):
292 outputLabel +
'_%SYS%',
296 alg.preselection =
'unifiedSelectForOR'
299 if self.
muons !=
"" :
302 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORMuonsSelectAlg' )
303 muons, alg.preselection = config.readNameAndSelection (self.
muons)
304 alg.particles = muons
305 alg.selectionDecoration = inputLabel +
',as_char'
306 if enableOutput(self.
muons, muonsSelectionName):
308 config.addOutputVar (self.
muons.
split(
'.')[0],
309 outputLabel +
'_%SYS%',
313 alg.preselection =
'unifiedSelectForOR'
319 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORTausSelectAlg' )
320 taus, alg.preselection = config.readNameAndSelection (self.
taus)
322 alg.selectionDecoration = inputLabel +
',as_char'
323 if enableOutput(self.
taus, tausSelectionName):
325 config.addOutputVar (self.
taus.
split(
'.')[0],
326 outputLabel +
'_%SYS%',
330 alg.preselection =
'unifiedSelectForOR'
336 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORJetsSelectAlg' )
337 jets, alg.preselection = config.readNameAndSelection (self.
jets)
339 alg.selectionDecoration = inputLabel +
',as_char'
340 if enableOutput(self.
jets, jetsSelectionName):
342 config.addOutputVar (self.
jets.
split(
'.')[0],
343 outputLabel +
'_%SYS%',
347 alg.preselection =
'unifiedSelectForOR'
353 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORFatJetsSelectAlg' )
354 fatJets, alg.preselection = config.readNameAndSelection (self.
fatJets)
355 alg.particles = fatJets
356 alg.selectionDecoration = inputLabel +
',as_char'
357 if enableOutput(self.
fatJets, fatJetsSelectionName):
360 outputLabel +
'_%SYS%',
364 alg.preselection =
'unifiedSelectForOR'
370 alg = config.createAlgorithm(
'CP::OverlapRemovalAlg',
'OverlapRemovalAlg' )
371 alg.OutputLabel = outputLabel
373 alg.affectingSystematicsFilter =
'.*'
375 alg.electrons = electrons
376 alg.electronsDecoration = outputLabel +
'_%SYS%,as_char'
377 config.addSelection (self.
electrons.
split(
'.')[0], electronsSelectionName, alg.electronsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
380 alg.muonsDecoration = outputLabel +
'_%SYS%,as_char'
381 config.addSelection (self.
muons.
split(
'.')[0], muonsSelectionName, alg.muonsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
384 alg.tausDecoration = outputLabel +
'_%SYS%,as_char'
385 config.addSelection (self.
taus.
split(
'.')[0], tausSelectionName, alg.tausDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
388 alg.jetsDecoration = outputLabel +
'_%SYS%,as_char'
389 config.addSelection (self.
jets.
split(
'.')[0], jetsSelectionName, alg.jetsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
391 alg.photons = photons
392 alg.photonsDecoration = outputLabel +
'_%SYS%,as_char'
393 config.addSelection (self.
photons.
split(
'.')[0], photonsSelectionName, alg.photonsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
395 alg.fatJets = fatJets
396 alg.fatJetsDecoration = outputLabel +
'_%SYS%,as_char'
397 config.addSelection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, alg.fatJetsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
400 config.addPrivateTool(
'overlapTool',
'ORUtils::OverlapRemovalTool' )
401 alg.overlapTool.InputLabel = inputLabel
402 alg.overlapTool.OutputLabel = outputLabel
409 alg.overlapTool.OutputPassValue =
True
413 config.addPrivateTool(
'overlapTool.EleEleORT',
414 'ORUtils::EleEleOverlapTool' )
415 alg.overlapTool.EleEleORT.InputLabel = inputLabel
416 alg.overlapTool.EleEleORT.OutputLabel = outputLabel
417 alg.overlapTool.EleEleORT.LinkOverlapObjects = self.linkOverlapObjects
418 alg.overlapTool.EleEleORT.OutputPassValue =
True
422 config.addPrivateTool(
'overlapTool.EleMuORT',
423 'ORUtils::EleMuSharedTrkOverlapTool' )
424 alg.overlapTool.EleMuORT.InputLabel = inputLabel
425 alg.overlapTool.EleMuORT.OutputLabel = outputLabel
426 alg.overlapTool.EleMuORT.LinkOverlapObjects = self.linkOverlapObjects
427 alg.overlapTool.EleMuORT.OutputPassValue =
True
431 config.addPrivateTool(
'overlapTool.EleJetORT',
432 'ORUtils::EleJetOverlapTool' )
433 alg.overlapTool.EleJetORT.InputLabel = inputLabel
434 alg.overlapTool.EleJetORT.OutputLabel = outputLabel
435 alg.overlapTool.EleJetORT.LinkOverlapObjects = self.linkOverlapObjects
436 alg.overlapTool.EleJetORT.BJetLabel = self.bJetLabel
437 alg.overlapTool.EleJetORT.InnerDR = self.InnerDR
438 alg.overlapTool.EleJetORT.OuterDR = self.OuterDR
439 alg.overlapTool.EleJetORT.UseSlidingDR = self.boostedLeptons
440 alg.overlapTool.EleJetORT.EnableUserPriority = self.enableUserPriority
441 alg.overlapTool.EleJetORT.OutputPassValue =
True
445 config.addPrivateTool(
'overlapTool.MuJetORT',
446 'ORUtils::MuJetOverlapTool' )
447 alg.overlapTool.MuJetORT.InputLabel = inputLabel
448 alg.overlapTool.MuJetORT.OutputLabel = outputLabel
449 alg.overlapTool.MuJetORT.LinkOverlapObjects = self.linkOverlapObjects
450 alg.overlapTool.MuJetORT.BJetLabel = self.bJetLabel
451 alg.overlapTool.MuJetORT.InnerDR = self.InnerDR
452 alg.overlapTool.MuJetORT.OuterDR = self.OuterDR
453 alg.overlapTool.MuJetORT.UseSlidingDR = self.boostedLeptons
454 alg.overlapTool.MuJetORT.EnableUserPriority = self.enableUserPriority
455 alg.overlapTool.MuJetORT.OutputPassValue =
True
456 alg.overlapTool.MuJetORT.AllowNoPV = self.allowNoPV
460 config.addPrivateTool(
'overlapTool.TauEleORT',
461 'ORUtils::DeltaROverlapTool' )
462 alg.overlapTool.TauEleORT.InputLabel = inputLabel
463 alg.overlapTool.TauEleORT.OutputLabel = outputLabel
464 alg.overlapTool.TauEleORT.LinkOverlapObjects = self.linkOverlapObjects
465 alg.overlapTool.TauEleORT.DR = 0.2
466 alg.overlapTool.TauEleORT.OutputPassValue =
True
470 config.addPrivateTool(
'overlapTool.TauMuORT',
471 'ORUtils::DeltaROverlapTool' )
472 alg.overlapTool.TauMuORT.InputLabel = inputLabel
473 alg.overlapTool.TauMuORT.OutputLabel = outputLabel
474 alg.overlapTool.TauMuORT.LinkOverlapObjects = self.linkOverlapObjects
475 alg.overlapTool.TauMuORT.DR = 0.2
476 alg.overlapTool.TauMuORT.OutputPassValue =
True
481 config.addPrivateTool(
'overlapTool.TauJetORT',
482 'ORUtils::TauAntiTauJetOverlapTool' )
483 alg.overlapTool.TauJetORT.TauLabel = self.antiTauIDTauLabel
484 alg.overlapTool.TauJetORT.AntiTauLabel = self.antiTauLabel
485 alg.overlapTool.TauJetORT.BJetLabel = self.antiTauBJetLabel
487 config.addPrivateTool(
'overlapTool.TauJetORT',
488 'ORUtils::DeltaROverlapTool' )
490 alg.overlapTool.TauJetORT.InputLabel = inputLabel
491 alg.overlapTool.TauJetORT.OutputLabel = outputLabel
492 alg.overlapTool.TauJetORT.LinkOverlapObjects = self.linkOverlapObjects
493 alg.overlapTool.TauJetORT.DR = 0.2
494 alg.overlapTool.TauJetORT.EnableUserPriority = self.enableUserPriority
495 alg.overlapTool.TauJetORT.OutputPassValue =
True
499 config.addPrivateTool(
'overlapTool.PhoEleORT',
500 'ORUtils::DeltaROverlapTool' )
501 alg.overlapTool.PhoEleORT.InputLabel = inputLabel
502 alg.overlapTool.PhoEleORT.OutputLabel = outputLabel
503 alg.overlapTool.PhoEleORT.LinkOverlapObjects = self.linkOverlapObjects
504 alg.overlapTool.PhoEleORT.OutputPassValue =
True
506 alg.overlapTool.PhoEleORT.SwapContainerPrecedence =
True
510 config.addPrivateTool(
'overlapTool.PhoMuORT',
511 'ORUtils::DeltaROverlapTool' )
512 alg.overlapTool.PhoMuORT.InputLabel = inputLabel
513 alg.overlapTool.PhoMuORT.OutputLabel = outputLabel
514 alg.overlapTool.PhoMuORT.LinkOverlapObjects = self.linkOverlapObjects
515 alg.overlapTool.PhoMuORT.OutputPassValue =
True
517 alg.overlapTool.PhoMuORT.SwapContainerPrecedence =
True
521 config.addPrivateTool(
'overlapTool.PhoJetORT',
522 'ORUtils::DeltaROverlapTool' )
523 alg.overlapTool.PhoJetORT.InputLabel = inputLabel
524 alg.overlapTool.PhoJetORT.OutputLabel = outputLabel
525 alg.overlapTool.PhoJetORT.LinkOverlapObjects = self.linkOverlapObjects
526 alg.overlapTool.PhoJetORT.EnableUserPriority = self.enableUserPriority
527 alg.overlapTool.PhoJetORT.OutputPassValue =
True
531 config.addPrivateTool(
'overlapTool.EleFatJetORT',
532 'ORUtils::DeltaROverlapTool' )
533 alg.overlapTool.EleFatJetORT.InputLabel = inputLabel
534 alg.overlapTool.EleFatJetORT.OutputLabel = outputLabel
535 alg.overlapTool.EleFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
536 alg.overlapTool.EleFatJetORT.DR = 1.0
537 alg.overlapTool.EleFatJetORT.OutputPassValue =
True
541 config.addPrivateTool(
'overlapTool.JetFatJetORT',
542 'ORUtils::DeltaROverlapTool' )
543 alg.overlapTool.JetFatJetORT.InputLabel = inputLabel
544 alg.overlapTool.JetFatJetORT.OutputLabel = outputLabel
545 alg.overlapTool.JetFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
546 alg.overlapTool.JetFatJetORT.DR = 1.0
547 alg.overlapTool.JetFatJetORT.OutputPassValue =
True
551 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORElectronsCopyAlg')
552 alg.particles = electrons
553 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
555 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORMuonsCopyAlg')
556 alg.particles = muons
557 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
559 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORTausCopyAlg')
561 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
563 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORJetsCopyAlg')
565 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
567 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORPhotonsCopyAlg')
568 alg.particles = photons
569 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
571 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORFatJetsCopyAlg')
572 alg.particles = fatJets
573 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
577 if self.preselectLabel
is not None :
578 preselectLabel = self.preselectLabel
580 preselectLabel = outputLabel
583 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORElectronsPreselectionAlg')
584 alg.particles = electrons
585 alg.preselection =
'&&'.join (config.getPreselection (self.
electrons.
split(
'.')[0], electronsSelectionName, asList=
True)
586 + [outputLabel +
'_%SYS%,as_char'])
587 alg.selectionDecoration = preselectLabel
588 config.addSelection (self.
electrons.
split(
'.')[0], electronsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
590 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORMuonsPreselectionAlg')
591 alg.particles = muons
592 alg.preselection =
'&&'.join (config.getPreselection (self.
muons.
split(
'.')[0], muonsSelectionName, asList=
True)
593 + [outputLabel +
'_%SYS%,as_char'])
594 alg.selectionDecoration = preselectLabel
595 config.addSelection (self.
muons.
split(
'.')[0], muonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
597 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORTausPreselectionAlg')
599 alg.preselection =
'&&'.join (config.getPreselection (self.
taus.
split(
'.')[0], tausSelectionName, asList=
True)
600 + [outputLabel +
'_%SYS%,as_char'])
601 alg.selectionDecoration = preselectLabel
602 config.addSelection (self.
taus.
split(
'.')[0], tausSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
604 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORJetsPreselectionAlg')
606 alg.preselection =
'&&'.join (config.getPreselection (self.
jets.
split(
'.')[0], jetsSelectionName, asList=
True)
607 + [outputLabel +
'_%SYS%,as_char'])
608 alg.selectionDecoration = preselectLabel
609 config.addSelection (self.
jets.
split(
'.')[0], jetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
611 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORPhotonsPreselectionAlg')
612 alg.particles = photons
613 alg.preselection =
'&&'.join (config.getPreselection (self.
photons.
split(
'.')[0], photonsSelectionName, asList=
True)
614 + [outputLabel +
'_%SYS%,as_char'])
615 alg.selectionDecoration = preselectLabel
616 config.addSelection (self.
photons.
split(
'.')[0], photonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
618 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORFatJetsPreselectionAlg')
619 alg.particles = fatJets
620 alg.preselection =
'&&'.join (config.getPreselection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, asList=
True)
621 + [outputLabel +
'_%SYS%,as_char'])
622 alg.selectionDecoration = preselectLabel
623 config.addSelection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)